Last active
August 29, 2015 14:13
-
-
Save sycobuny/6ae1dbb55ca8aee418f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
MyApp = angular.module('my-app', []) | |
MyApp.run(function($rootScope) { | |
testFactory.callFakeAJAX().success(function(response) { | |
console.log(response.data) | |
}) | |
}) | |
/*********** | |
* MOCKING * | |
***********/ | |
MyApp.service('mock', function() { | |
var service = {} | |
service.response = function(mockReturn) { | |
return { | |
success: function(callback) { | |
callback({ | |
'status': 'success', | |
'data': mockReturn | |
}) | |
}, | |
failure: function(callback) { | |
callback() | |
} | |
} | |
} | |
return service | |
}) | |
/************* | |
* FACTORIES * | |
*************/ | |
MyApp.factory('testFactory', function(mock) { | |
var factory = {} | |
factory.callFakeAJAX = function() { | |
return mock.response(['hi']) | |
} | |
return factory | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment