-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.js
42 lines (38 loc) · 1.01 KB
/
models.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var chai = require('chai');
var should = chai.should();
var User = require('../models/User');
describe('User Model', function() {
it('should create a new user', function(done) {
var user = new User({
email: 'test@gmail.com',
password: 'password'
});
user.save(function(err) {
if (err) return done(err);
done();
})
});
it('should not create a user with the unique email', function(done) {
var user = new User({
email: 'test@gmail.com',
password: 'password'
});
user.save(function(err) {
if (err) err.code.should.equal(11000);
done();
});
});
it('should find user by email', function(done) {
User.findOne({ email: 'test@gmail.com' }, function(err, user) {
if (err) return done(err);
user.email.should.equal('test@gmail.com');
done();
});
});
it('should delete a user', function(done) {
User.remove({ email: 'test@gmail.com' }, function(err) {
if (err) return done(err);
done();
});
});
});