Last active
December 28, 2015 17:39
-
-
Save sorribas/7537110 to your computer and use it in GitHub Desktop.
beforeEach hook in mocha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken from http://visionmedia.github.io/mocha/ | |
describe('Connection', function(){ | |
var db = new Connection | |
, tobi = new User('tobi') | |
, loki = new User('loki') | |
, jane = new User('jane'); | |
beforeEach(function(done){ | |
db.clear(function(err){ | |
if (err) return done(err); | |
db.save([tobi, loki, jane], done); | |
}); | |
}) | |
describe('#find()', function(){ | |
it('respond with matching records', function(done){ | |
db.find({ type: 'User' }, function(err, res){ | |
if (err) return done(err); | |
res.should.have.length(3); | |
done(); | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment