forked from meanjs/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.server.model.tests.js
More file actions
67 lines (57 loc) · 1.29 KB
/
Copy patharticle.server.model.tests.js
File metadata and controls
67 lines (57 loc) · 1.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
/**
* Module dependencies.
*/
var should = require('should'),
mongoose = require('mongoose'),
User = mongoose.model('User'),
Article = mongoose.model('Article');
/**
* Globals
*/
var user,
article;
/**
* Unit tests
*/
describe('Article Model Unit Tests:', function () {
beforeEach(function (done) {
user = new User({
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: 'test@test.com',
username: 'username',
password: 'M3@n.jsI$Aw3$0m3'
});
user.save(function () {
article = new Article({
title: 'Article Title',
content: 'Article Content',
user: user
});
done();
});
});
describe('Method Save', function () {
it('should be able to save without problems', function (done) {
this.timeout(10000);
article.save(function (err) {
should.not.exist(err);
return done();
});
});
it('should be able to show an error when try to save without title', function (done) {
article.title = '';
article.save(function (err) {
should.exist(err);
return done();
});
});
});
afterEach(function (done) {
Article.remove().exec(function () {
User.remove().exec(done);
});
});
});