From 2fade3342ccc9067f8099ed14686240c199f3936 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Thu, 20 Mar 2014 14:53:22 +0000 Subject: [PATCH] Test cleanup --- Gruntfile.js | 2 ++ lib/config/env/test.js | 8 ++++---- lib/models/promotion.js | 5 ++--- package.json | 3 ++- test/server/promotion/model.js | 37 +++++++++++++++++----------------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 554df22..d84021e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -547,4 +547,6 @@ module.exports = function (grunt) { 'test', 'build' ]); + + grunt.loadNpmTasks('grunt-mocha-debug'); }; diff --git a/lib/config/env/test.js b/lib/config/env/test.js index 452ec34..78e1925 100644 --- a/lib/config/env/test.js +++ b/lib/config/env/test.js @@ -1,8 +1,8 @@ 'use strict'; module.exports = { - env: 'test', - mongo: { - uri: 'mongodb://localhost/roboto-test' - } + env: 'test', + mongo: { + uri: 'mongodb://localhost/roboto-test' + } }; diff --git a/lib/models/promotion.js b/lib/models/promotion.js index 75881b8..aec22f3 100644 --- a/lib/models/promotion.js +++ b/lib/models/promotion.js @@ -12,11 +12,10 @@ var PromotionSchema = new Schema({ /* Indexes */ PromotionSchema.index({title: 1, user: 1}, {unique: true}); -var _model = mongoose.model('Promotion', PromotionSchema); /* Operations */ PromotionSchema.statics.findByTitle = function(title, cb){ - console.log("findByTitle: " + title); - _model.findOne({title: title}, cb); + this.findOne({title: title}, cb); }; +mongoose.model('Promotion', PromotionSchema); diff --git a/package.json b/package.json index fa706e3..bc05317 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ "open": "~0.0.4", "mocha": "~1.18.2", "mongodb": "~1.3.23", - "mocha-mongoose": "~1.0.1" + "mocha-mongoose": "~1.0.1", + "grunt-mocha-debug": "0.0.10" }, "engines": { "node": ">=0.10.0" diff --git a/test/server/promotion/model.js b/test/server/promotion/model.js index 094f002..4a3548c 100644 --- a/test/server/promotion/model.js +++ b/test/server/promotion/model.js @@ -10,24 +10,24 @@ var user; describe('Promotion Model', function() { before(function(done) { - user = new User({ - provider: 'local', - name: 'Fake User', - email: 'test@test.com', - password: 'password' - }); - promotion = new Promotion({ - title: 'Test Prom 1', - user: user - }); - promotion2 = new Promotion({ - title: 'Test Prom 1', - user: user - }); - // Clear promotions before testing - Promotion.remove().exec(); - User.remove().exec(); - done(); + user = new User({ + provider: 'local', + name: 'Fake User', + email: 'test@test.com', + password: 'password' + }); + promotion = new Promotion({ + title: 'Test Prom 1', + user: user + }); + promotion2 = new Promotion({ + title: 'Test Prom 1', + user: user + }); + // Clear promotions before testing + Promotion.remove().exec(); + User.remove().exec(); + done(); }); afterEach(function(done) { @@ -75,6 +75,7 @@ describe('Promotion Model', function() { }); describe('Search methods', function(){ it('should find promotion by title', function(done){ + debugger; Promotion.findByTitle('Test Prom 1', function(result){ should.exist(result); result.title.should.equal('Test Prom 1');