fake-parse
v0.4.1
Published
Simple fake implementations of the Parse.com JavaScript API
Downloads
4
Readme
Fake Parse
Simple fake implementations of the Parse.com JavaScript API.
Usage
This is designed to be used with the excellent Karma test runner.
It allows you to easily setup fake data on a model-by-model basis.
The following is a contrived example using Jasmine:
/* controllers/home.js */
angular.module('yourApp', [])
.controller('HomeController', function () {
var _this = this;
this.usernames = [];
this.loadUsernames = function () {
return new Parse.Query('User')
.find()
.then(function (users) {
_this.usernames = users.map(function (user) {
return user.getUsername();
});
return _this.usernames;
});
};
});
/* test/controllers/home.spec.js */
describe('HomeController', function () {
var controller;
beforeEach(inject(function ($controller) {
controller = $controller('HomeController');
}));
it('should get usernames', function (done) {
Parse.MockData.setData('User', [
new Parse.User({
id: 'fake-1',
username: 'fake-user-1',
email: '[email protected]'
}),
new Parse.User({
id: 'fake-2',
username: 'fake-user-2',
email: '[email protected]'
})
]);
controller.loadUsers()
.then(function (usernames) {
expect(controller.usernames).toEqual(['fake-user-1', 'fake-user-2']);
}).then(done, done.fail);
});
});