Files
meanTorrent/modules/articles/tests/server/article.server.model.tests.js
Ryan Hutchison ef3a3f9548 formatting reboot (space-2 and consistency)
JSCS fixes

update editorconfig
2015-07-31 10:04:02 -04:00

65 lines
1.2 KiB
JavaScript

'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: 'password'
});
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) {
return article.save(function (err) {
should.not.exist(err);
done();
});
});
it('should be able to show an error when try to save without title', function (done) {
article.title = '';
return article.save(function (err) {
should.exist(err);
done();
});
});
});
afterEach(function (done) {
Article.remove().exec(function () {
User.remove().exec(done);
});
});
});