Created
March 24, 2014 14:59
-
-
Save gruppjo/9741785 to your computer and use it in GitHub Desktop.
$httpBackend ngMockE2E
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define new module myApp-mock | |
angular.module('myApp-mock', ['ngMockE2E']) | |
// we want to use $httpBackend mock | |
.run(function($httpBackend) { | |
$httpBackend.whenGET(/.*/).passThrough(); | |
$httpBackend.whenPOST(/^http:\/\/labdemcap.*/).respond(function (method, url, data) { | |
data = JSON.parse(data); | |
var sapFunction = 'sap_function'; | |
sapFunction = data.service.request[sapFunction]; | |
var result = mockData[sapFunction]; | |
return [200, result, {}]; // status, result, headers | |
}); | |
}); | |
// add module to myApp | |
angular.module('myApp').requires.push('myApp-mock'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment