user: add spec
parent
01f0131f5d
commit
05de4870b0
@ -0,0 +1,54 @@
|
||||
// this test currently needs to talk to the redis database.
|
||||
// get the redis config info from root directory's config.json:
|
||||
var winston = require('winston');
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
winston.error('Encountered error while running test suite: ' + err.message);
|
||||
});
|
||||
|
||||
var assert = require('assert'),
|
||||
RDB = require('../mocks/redismock');
|
||||
|
||||
var User = require('../src/user');
|
||||
|
||||
describe('User', function() {
|
||||
var userData;
|
||||
|
||||
beforeEach(function(){
|
||||
userData = {
|
||||
name: 'John Smith',
|
||||
password: 'swordfish',
|
||||
email: 'john@example.com',
|
||||
callback: undefined
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
describe('when created', function() {
|
||||
it('should be created properly', function(done){
|
||||
User.create(userData.name, userData.password, userData.email, function(error,userId){
|
||||
assert.equal(error, null, 'was created with error');
|
||||
assert.ok(userId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should have a valid email', function() {
|
||||
assert.throws(
|
||||
User.create(userData.name, userData.password, 'fakeMail',function(){}),
|
||||
Error,
|
||||
'does not validate email'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
after(function() {
|
||||
//Clean up
|
||||
RDB.send_command('flushdb', [], function(error){
|
||||
if(error){
|
||||
winston.error(error);
|
||||
throw new Error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue