mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-25 05:54:51 -05:00
Update jasmine for server tests to 2.4.1, fix server focus tests
Before if you focused tests, they would bypass the setup "tests" and break. Now the server setup logic is in a beforeEach.
This commit is contained in:
parent
6772d5bdf4
commit
51408a94de
2 changed files with 54 additions and 39 deletions
|
@ -98,7 +98,7 @@
|
|||
"css-brunch": "^1.7.0",
|
||||
"fs-extra": "^0.26.2",
|
||||
"jade-brunch": "1.7.5",
|
||||
"jasmine": "^2.3.2",
|
||||
"jasmine": "^2.4.1",
|
||||
"javascript-brunch": "> 1.0 < 1.8",
|
||||
"karma": "~0.13",
|
||||
"karma-chrome-launcher": "~0.1.2",
|
||||
|
|
|
@ -38,14 +38,21 @@ if (database.generateMongoConnectionString() !== dbString) {
|
|||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 120; // for long Stripe tests
|
||||
|
||||
describe('Server Test Helper', function() {
|
||||
it('starts the test server', function(done) {
|
||||
var server = require('../../server');
|
||||
server.startServer(done);
|
||||
});
|
||||
var initialized = false;
|
||||
beforeEach(function(done) {
|
||||
if (initialized) {
|
||||
return done();
|
||||
}
|
||||
|
||||
it('checks the db is fairly empty', function(done) {
|
||||
// 5. Check actual database.
|
||||
var async = require('async');
|
||||
async.series([
|
||||
function(cb) {
|
||||
// Start the server
|
||||
var server = require('../../server');
|
||||
server.startServer(cb);
|
||||
},
|
||||
function(cb) {
|
||||
// 5. Check actual database
|
||||
var User = require('../../server/users/User');
|
||||
User.find({}).count(function(err, count) {
|
||||
// For this to serve as a line of defense against testing with the
|
||||
|
@ -57,24 +64,32 @@ describe('Server Test Helper', function() {
|
|||
process.exit(1);
|
||||
}
|
||||
GLOBAL.mc.lists.subscribe = _.noop;
|
||||
done()
|
||||
cb()
|
||||
});
|
||||
});
|
||||
|
||||
it('clears the db', function(done) {
|
||||
},
|
||||
function(cb) {
|
||||
// Clear db
|
||||
var mongoose = require('mongoose');
|
||||
mongoose.connection.db.command({dropDatabase:1}, function(err, result) {
|
||||
if (err) { console.log(err); }
|
||||
done();
|
||||
cb(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('initializes products', function(done) {
|
||||
},
|
||||
function(cb) {
|
||||
// Initialize products
|
||||
var request = require('request');
|
||||
request.get(getURL('/db/products'), function(err, res, body) {
|
||||
expect(err).toBe(null);
|
||||
expect(res.statusCode).toBe(200);
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
function(err) {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
initialized = true;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
Loading…
Reference in a new issue