Node.js based forum software built for the modern web
user: add spec
Denis Wolf05de4870b0c9
diff --git a/tests/user.js b/tests/user.jsnew file mode 100644index 0000000000..cb89ac1fc9--- /dev/null+++ b/tests/user.js@@ -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: '[email protected]',+ 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);+ }+ });+ });+});\ No newline at end of file