mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-18 01:50:37 +01:00
Better user model behavior and test teardown
This commit is contained in:
@@ -52,7 +52,14 @@ describe('<Unit Test>', function() {
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
Article.remove({});
|
||||
User.remove({});
|
||||
done();
|
||||
});
|
||||
after(function(done){
|
||||
Article.remove().exec();
|
||||
User.remove().exec();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,15 +19,33 @@ describe('<Unit Test>', function() {
|
||||
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) {
|
||||
return user.save(function(err) {
|
||||
should.not.exist(err);
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,7 +59,8 @@ describe('<Unit Test>', function() {
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
User.remove().exec();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user