Skip to content

Instantly share code, notes, and snippets.

@gruppjo
Created March 24, 2014 14:59
Show Gist options
  • Save gruppjo/9741785 to your computer and use it in GitHub Desktop.
Save gruppjo/9741785 to your computer and use it in GitHub Desktop.
$httpBackend ngMockE2E
// 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