Skip to content

Instantly share code, notes, and snippets.

@metasansana
Last active August 29, 2015 14:12
Show Gist options
  • Save metasansana/6b67f9985e9b821808d0 to your computer and use it in GitHub Desktop.
Save metasansana/6b67f9985e9b821808d0 to your computer and use it in GitHub Desktop.
Running a multiple functional tests for a keystone app.
var q = require('q');
require('must');
var keystone;
var sockets = [];
beforeEach(function(done) {
require.cache = {};
keystone = require('keystone');
keystone.init();
keystone.set('cookie secret', 'funky');
keystone.set('logger', false);
keystone.set('port', 8000);
keystone.start(function() {
keystone.httpServer.on('connection', function(socket) {
sockets.push(socket);
});
done();
});
});
afterEach(function() {
var list = [];
console.log('cleaning up');
sockets.forEach(function(socket) {
console.log('closing ', socket);
list.push(q.ninvoke(socket, 'destroy'));
});
console.log('closing http');
list.push(q.ninvoke(keystone.httpServer, 'close'));
keystone.httpServer.on('close', function() {
console.log('closing the connections');
});
keystone.mongoose.disconnect();
list.push(q.ninvoke(keystone.mongoose, 'disconnect'));
return q.all(list);
});
describe('this silly test', function() {
it('should work', function() {
console.log('Work once');
'string'.must.equal('string');
});
});
describe('this silly test part two', function() {
it('should work twice', function() {
console.log('work twice');
'string'.must.equal('string');
});
});
describe('this silly test part three', function() {
it('should work thrice', function() {
console.log('work thrice');
'string'.must.equal('string');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment