2015-09-03 18:21:56 +00:00
|
|
|
// 'use strict';
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// /**
|
|
|
|
// * Module dependencies.
|
|
|
|
// */
|
|
|
|
// var should = require('should'),
|
|
|
|
// mongoose = require('mongoose'),
|
|
|
|
// User = mongoose.model('User');
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// /**
|
|
|
|
// * Globals
|
|
|
|
// */
|
|
|
|
// var user, user2;
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// /**
|
|
|
|
// * Unit tests
|
|
|
|
// */
|
|
|
|
// describe('User Model Unit Tests:', function() {
|
|
|
|
// beforeEach(function(done) {
|
|
|
|
// user = new User({
|
|
|
|
// firstName: 'Full',
|
|
|
|
// lastName: 'Name',
|
|
|
|
// email: 'test@test.com',
|
|
|
|
// username: 'test@test.com',
|
|
|
|
// password: 'password',
|
|
|
|
// provider: 'local'
|
|
|
|
// });
|
|
|
|
// user2 = new User({
|
|
|
|
// firstName: 'Full',
|
|
|
|
// lastName: 'Name',
|
|
|
|
// email: 'test@test.com',
|
|
|
|
// username: 'test@test.com',
|
|
|
|
// password: 'password',
|
|
|
|
// provider: 'local'
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// done();
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// describe('Method Save', function() {
|
|
|
|
// it('should begin with no users', function(done) {
|
|
|
|
// User.find({}, function(err, users) {
|
|
|
|
// users.should.have.length(0);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// it('should be able to save without problems', function(done) {
|
|
|
|
// user.save(done);
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// it('should fail to save an existing user again', function(done) {
|
|
|
|
// user.save(function() {
|
|
|
|
// user2.save(function(err) {
|
|
|
|
// should.exist(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// it('should be able to show an error when try to save without first name', function(done) {
|
|
|
|
// user.firstName = '';
|
|
|
|
// return user.save(function(err) {
|
|
|
|
// should.exist(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// describe('Method findUniqueUsername', function() {
|
|
|
|
// beforeEach(function(done) {
|
|
|
|
// User.find({}, function(err, users) {
|
|
|
|
// users.should.have.length(0);
|
|
|
|
// user.save(done);
|
|
|
|
// });
|
|
|
|
// });
|
2015-08-07 21:02:44 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// it('should be able to find unique version of existing username without problems', function(done) {
|
|
|
|
// User.findUniqueUsername(user.username, null, function (availableUsername) {
|
|
|
|
// availableUsername.should.not.equal(user.username);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-08-07 21:02:44 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// });
|
2015-08-07 21:02:44 +00:00
|
|
|
|
2015-09-03 18:21:56 +00:00
|
|
|
// afterEach(function(done) {
|
|
|
|
// User.remove().exec(done);
|
|
|
|
// });
|
|
|
|
// });
|