The first beforeEach
clears out the User collection...which works fine for the first set of tests (the #save() describe)...but not for the 2nd describe("#find()").
describe('User', function(){
beforeEach(function(done){
//clear out db
User.remove(done);
});
describe('#save()', function(){
beforeEach(function(done){
user = new User(fakeUser);
done();
});
it('should have username property', function(done){
});
it('should not save if username is not present', function(done){
});
});
describe('#find()', function(){
beforeEach(function(done){
user = new User(fakeUser);
user.save(function(err, user){
done();
});
});
it('should find user by email', function(done){
});
it('should find user by username', function(done){
});
});
});
What does the very first beforeEac
h refer to? I thought it runs for each child describe
, but apparently not.
My bad, I needed to add after
to drop the collection.