Cleanup
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
app = require('../../server'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
Article = mongoose.model('Article');
|
||||
|
||||
//Globals
|
||||
var user;
|
||||
var article;
|
||||
|
||||
//The tests
|
||||
describe('<Unit Test>', function() {
|
||||
describe('Model Article:', function() {
|
||||
beforeEach(function(done) {
|
||||
user = new User({
|
||||
name: 'Full name',
|
||||
email: 'test@test.com',
|
||||
username: 'user',
|
||||
password: 'password'
|
||||
});
|
||||
|
||||
user.save(function(err) {
|
||||
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({});
|
||||
User.remove({});
|
||||
done();
|
||||
});
|
||||
after(function(done){
|
||||
Article.remove().exec();
|
||||
User.remove().exec();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
app = require('../../server'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User');
|
||||
|
||||
//Globals
|
||||
var user;
|
||||
|
||||
//The tests
|
||||
describe('<Unit Test>', function() {
|
||||
describe('Model User:', function() {
|
||||
before(function(done) {
|
||||
user = new User({
|
||||
name: 'Full name',
|
||||
email: 'test@test.com',
|
||||
username: 'user',
|
||||
password: 'password'
|
||||
});
|
||||
user2 = new User({
|
||||
name: 'Full name',
|
||||
email: 'test@test.com',
|
||||
username: 'user',
|
||||
password: 'password'
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
describe('Method Save', function() {
|
||||
it('should begin with no users', function(done) {
|
||||
User.find({}, function(err, users) {
|
||||
users.should.have.length(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to save whithout problems', function(done) {
|
||||
user.save(done);
|
||||
});
|
||||
|
||||
it('should fail to save an existing user again', function(done) {
|
||||
user.save();
|
||||
return user2.save(function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to show an error when try to save without name', function(done) {
|
||||
user.name = '';
|
||||
return user.save(function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
User.remove().exec();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user