Skip to content

Instantly share code, notes, and snippets.

@Sharondio
Last active December 30, 2015 09:28
Show Gist options
  • Save Sharondio/7809034 to your computer and use it in GitHub Desktop.
Save Sharondio/7809034 to your computer and use it in GitHub Desktop.
Example of a simple service mock.
// MOCK SERVICES
beforeEach(mock.module('app-name', function ($provide) {
getContentData = require('../data/getContentData.json');
getVersionsData = require('../data/getVersionsData.json');
newPost = require('../data/newPost.json');
fullPost = require('../data/fullPost.json');
$provide.value('ContentSvc', {
find: function(filter, options, cb) {
return cb(error, getContentData);
},
findOne: function(id, cb) {
return cb(error, getContentData[0]);
},
findVersions: function(filter, cb) {
return cb(error, getVersionsData);
},
saveArticle: function(content, cb) {
return cb(error);
},
addComment: function(article_id, comment, cb) {
return cb(error);
},
deleteComment: function(article_id, comment, cb) {
return cb(error);
}
});
}));
@Sharondio
Copy link
Author

The "error" you see is being set in the expect block so I could test with and without errors being generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment