2015-07-27 18:11:43 +00:00
|
|
|
// 'use strict';
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// /**
|
|
|
|
// * Module dependencies.
|
|
|
|
// */
|
|
|
|
// var should = require('should'),
|
|
|
|
// mongoose = require('mongoose'),
|
|
|
|
// User = mongoose.model('User'),
|
|
|
|
// Article = mongoose.model('Article');
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// /**
|
|
|
|
// * Globals
|
|
|
|
// */
|
|
|
|
// var user, article;
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00: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: 'password'
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// user.save(function() {
|
|
|
|
// article = new Article({
|
|
|
|
// title: 'Article Title',
|
|
|
|
// content: 'Article Content',
|
|
|
|
// user: user
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// describe('Method Save', function() {
|
|
|
|
// it('should be able to save without problems', function(done) {
|
|
|
|
// return article.save(function(err) {
|
|
|
|
// should.not.exist(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// it('should be able to show an error when try to save without title', function(done) {
|
|
|
|
// article.title = '';
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// return article.save(function(err) {
|
|
|
|
// should.exist(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
2015-06-29 22:51:29 +00:00
|
|
|
|
2015-07-27 18:11:43 +00:00
|
|
|
// afterEach(function(done) {
|
|
|
|
// Article.remove().exec(function() {
|
|
|
|
// User.remove().exec(done);
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|