Last active
December 30, 2015 09:28
-
-
Save Sharondio/7809034 to your computer and use it in GitHub Desktop.
Example of a simple service mock.
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
// 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); | |
} | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The "error" you see is being set in the expect block so I could test with and without errors being generated.