From e25c04433368f44a357bd44b2cfdb07f14d7061f Mon Sep 17 00:00:00 2001 From: Mikael Korpela Date: Sun, 28 Aug 2016 04:08:49 +0300 Subject: [PATCH] fix(core): Fixes issues with tests and Node v6 Fixes issues with Mocha tests and Node v6. Related to #1455 --- .../articles/tests/server/article.server.model.tests.js | 8 ++++---- modules/users/tests/server/user.server.routes.tests.js | 5 +++-- package.json | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/articles/tests/server/article.server.model.tests.js b/modules/articles/tests/server/article.server.model.tests.js index fb37701704..49463a16f4 100644 --- a/modules/articles/tests/server/article.server.model.tests.js +++ b/modules/articles/tests/server/article.server.model.tests.js @@ -43,18 +43,18 @@ describe('Article Model Unit Tests:', function () { describe('Method Save', function () { it('should be able to save without problems', function (done) { this.timeout(10000); - return article.save(function (err) { + article.save(function (err) { should.not.exist(err); - done(); + return done(); }); }); it('should be able to show an error when try to save without title', function (done) { article.title = ''; - return article.save(function (err) { + article.save(function (err) { should.exist(err); - done(); + return done(); }); }); }); diff --git a/modules/users/tests/server/user.server.routes.tests.js b/modules/users/tests/server/user.server.routes.tests.js index 7fbb05efde..9d0da694f1 100644 --- a/modules/users/tests/server/user.server.routes.tests.js +++ b/modules/users/tests/server/user.server.routes.tests.js @@ -1,6 +1,7 @@ 'use strict'; -var should = require('should'), +var semver = require('semver'), + should = require('should'), request = require('supertest'), path = require('path'), mongoose = require('mongoose'), @@ -104,7 +105,7 @@ describe('User CRUD tests', function () { // NodeJS v4 changed the status code representation so we must check // before asserting, to be comptabile with all node versions. - if (process.version.indexOf('v4') === 0 || process.version.indexOf('v5') === 0) { + if (semver.satisfies(process.versions.node, '>=4.0.0')) { signoutRes.text.should.equal('Found. Redirecting to /'); } else { signoutRes.text.should.equal('Moved Temporarily. Redirecting to /'); diff --git a/package.json b/package.json index c84f24055b..58dcaf457a 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "lodash": "~4.6.1", "lusca": "~1.3.0", "method-override": "~2.3.5", - "mocha": "~2.5.0", + "mocha": "~3.0.2", "mongoose": "~4.4.8", "morgan": "~1.7.0", "multer": "~1.1.0", @@ -111,7 +111,7 @@ "gulp-less": "~3.0.5", "gulp-livereload": "~3.8.1", "gulp-load-plugins": "~1.2.0", - "gulp-mocha": "~2.2.0", + "gulp-mocha": "~3.0.1", "gulp-ng-annotate": "~1.1.0", "gulp-nodemon": "~2.0.6", "gulp-protractor": "~2.1.0", @@ -129,9 +129,10 @@ "karma-ng-html2js-preprocessor": "~0.2.1", "karma-phantomjs-launcher": "~1.0.0", "load-grunt-tasks": "~3.4.1", - "mock-fs": "~3.7.0", + "mock-fs": "~3.11.0", "node-inspector": "~0.12.7", "run-sequence": "~1.1.5", + "semver": "~5.3.0", "should": "~8.2.2", "supertest": "~1.2.0" }