Files
meanTorrent/modules/articles/tests/server/article.server.model.tests.js

72 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2014-02-10 13:09:31 +02:00
'use strict';
/**
* Module dependencies.
*/
var should = require('should'),
mongoose = require('mongoose'),
User = mongoose.model('User'),
Article = mongoose.model('Article');
2014-02-10 13:09:31 +02:00
2014-04-02 19:34:32 +03:00
/**
* Globals
*/
var user,
article;
2014-02-10 13:09:31 +02:00
2014-04-02 19:34:32 +03:00
/**
* 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',
provider: 'local'
});
2014-02-10 13:09:31 +02:00
user.save()
.then(function () {
article = new Article({
title: 'Article Title',
content: 'Article Content',
user: user
});
2014-04-02 19:34:32 +03:00
done();
})
.catch(done);
});
2014-02-10 13:09:31 +02:00
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();
});
});
2014-02-10 13:09:31 +02:00
it('should be able to show an error when try to save without title', function (done) {
article.title = '';
2014-02-10 13:09:31 +02:00
article.save(function (err) {
should.exist(err);
return done();
});
});
});
2014-02-10 13:09:31 +02:00
afterEach(function (done) {
Article.remove().exec()
.then(User.remove().exec())
.then(done())
.catch(done);
});
2014-11-10 23:12:33 +02:00
});