diff --git a/core/test/functional/routes/api/redirects_spec.js b/core/test/functional/routes/api/redirects_spec.js index 07766caea6..b083e32fa3 100644 --- a/core/test/functional/routes/api/redirects_spec.js +++ b/core/test/functional/routes/api/redirects_spec.js @@ -109,7 +109,7 @@ describe('Redirects API', function () { afterEach(stopGhost); - it('no redirects file exists', function (done) { + it('no redirects file exists', function () { return startGhost({redirectsFile: false}) .then(function () { return new Promise(function (resolve) { @@ -150,12 +150,10 @@ describe('Redirects API', function () { var dataFiles = fs.readdirSync(config.getContentPath('data')); dataFiles.join(',').match(/(redirects)/g).length.should.eql(1); - done(); - }) - .catch(done); + }); }); - it('override', function (done) { + it('override', function () { return startGhost() .then(function () { return new Promise(function (resolve) { @@ -235,9 +233,7 @@ describe('Redirects API', function () { .then(function () { var dataFiles = fs.readdirSync(config.getContentPath('data')); dataFiles.join(',').match(/(redirects)/g).length.should.eql(3); - done(); - }) - .catch(done); + }); }); }); diff --git a/core/test/integration/api/api_schedules_spec.js b/core/test/integration/api/api_schedules_spec.js index 352ba9d81b..6d146cd831 100644 --- a/core/test/integration/api/api_schedules_spec.js +++ b/core/test/integration/api/api_schedules_spec.js @@ -14,9 +14,7 @@ var should = require('should'), describe('Schedules API', function () { var scope = {posts: []}; - after(function (done) { - testUtils.teardown(done); - }); + after(testUtils.teardown); describe('fn: getScheduledPosts', function () { before(function (done) { diff --git a/core/test/integration/migration_spec.js b/core/test/integration/migration_spec.js index 0483a1e321..37f77fa202 100644 --- a/core/test/integration/migration_spec.js +++ b/core/test/integration/migration_spec.js @@ -168,7 +168,7 @@ describe('Database Migration (special functions)', function () { describe('Populate', function () { beforeEach(testUtils.setup('default')); - it('should populate all fixtures correctly', function (done) { + it('should populate all fixtures correctly', function () { var props = { posts: Models.Post.findAll({include: ['tags']}), tags: Models.Tag.findAll(), @@ -226,9 +226,7 @@ describe('Database Migration (special functions)', function () { // Permissions result.permissions.length.should.eql(53); result.permissions.toJSON().should.be.CompletePermissions(); - - done(); - }).catch(done); + }); }); }); }); diff --git a/core/test/integration/model/base/listeners_spec.js b/core/test/integration/model/base/listeners_spec.js index 46ddf824db..c9577d57d6 100644 --- a/core/test/integration/model/base/listeners_spec.js +++ b/core/test/integration/model/base/listeners_spec.js @@ -34,11 +34,11 @@ describe('Models: listeners', function () { listeners = rewire(config.get('paths').corePath + '/server/models/base/listeners'); }); - afterEach(function (done) { + afterEach(function () { events.on.restore(); sandbox.restore(); scope.posts = []; - testUtils.teardown(done); + return testUtils.teardown(); }); describe('on timezone changed', function () { diff --git a/core/test/unit/adapters/scheduling/post-scheduling/index_spec.js b/core/test/unit/adapters/scheduling/post-scheduling/index_spec.js index 71bb53a564..731ab7da3b 100644 --- a/core/test/unit/adapters/scheduling/post-scheduling/index_spec.js +++ b/core/test/unit/adapters/scheduling/post-scheduling/index_spec.js @@ -54,9 +54,9 @@ describe('Scheduling: Post Scheduling', function () { sandbox.spy(scope.adapter, 'reschedule'); }); - afterEach(function (done) { + afterEach(function () { sandbox.restore(); - testUtils.teardown(done); + return testUtils.teardown(); }); describe('fn:init', function () { diff --git a/core/test/utils/index.js b/core/test/utils/index.js index e3bb3ed660..aaae07297f 100644 --- a/core/test/utils/index.js +++ b/core/test/utils/index.js @@ -625,16 +625,9 @@ setup = function setup() { var self = this, args = arguments; - return function setup(done) { + return function setup() { models.init(); - - if (done) { - initFixtures.apply(self, args).then(function () { - done(); - }).catch(done); - } else { - return initFixtures.apply(self, args); - } + return initFixtures.apply(self, args); }; }; @@ -768,7 +761,7 @@ togglePermalinks = function togglePermalinks(request, toggle) { * Has to run in a transaction for MySQL, otherwise the foreign key check does not work. * Sqlite3 has no truncate command. */ -teardown = function teardown(done) { +teardown = function teardown() { debug('Database teardown'); var tables = schemaTables.concat(['migrations']); @@ -777,16 +770,13 @@ teardown = function teardown(done) { .mapSeries(tables, function createTable(table) { return db.knex.raw('DELETE FROM ' + table + ';'); }) - .then(function () { - done && done(); - }) .catch(function (err) { // CASE: table does not exist if (err.errno === 1) { - return done && done(); + return Promise.resolve(); } - done && done(err); + throw err; }); } @@ -801,16 +791,13 @@ teardown = function teardown(done) { .then(function () { return db.knex.raw('SET FOREIGN_KEY_CHECKS=1;').transacting(trx); }) - .then(function () { - done && done(); - }) .catch(function (err) { // CASE: table does not exist if (err.errno === 1146) { - return done && done(); + return Promise.resolve(); } - return done ? done(err) : Promise.reject(err); + throw err; }); }); }; diff --git a/package.json b/package.json index 8f5ab4cb8a..637e878eea 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "istanbul": "0.4.5", "matchdep": "1.0.1", "minimist": "1.2.0", - "mocha": "3.5.3", + "mocha": "4.0.1", "nock": "9.1.3", "rewire": "3.0.2", "run-sequence": "1.2.2", diff --git a/yarn.lock b/yarn.lock index 5af1ad1a72..6b825c9b75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -888,6 +888,10 @@ commander@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" +commander@2.11.0, commander@^2.2.0, commander@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" + commander@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" @@ -898,10 +902,6 @@ commander@2.9.0: dependencies: graceful-readlink ">= 1.0.0" -commander@^2.2.0, commander@^2.9.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" - component-emitter@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -1165,19 +1165,13 @@ debug@2.2.0, debug@~2.2.0: dependencies: ms "0.7.1" -debug@2.6.8: - version "2.6.8" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" - dependencies: - ms "2.0.0" - debug@2.6.9, debug@2.x.x, debug@^2.1.3, debug@^2.2.0, debug@^2.6.2, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@^3.0.1, debug@^3.1.0: +debug@3.1.0, debug@^3.0.1, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -1274,9 +1268,9 @@ diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" -diff@3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" +diff@3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75" diff@^3.1.0: version "3.4.0" @@ -2161,14 +2155,14 @@ glob@5.0.15, glob@^5.0.15, glob@~5.0.0: once "^1.3.0" path-is-absolute "^1.0.0" -glob@7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" +glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.1: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" @@ -2182,17 +2176,6 @@ glob@^6.0.1: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.1: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - glob@~3.1.21: version "3.1.21" resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" @@ -2292,6 +2275,10 @@ graceful-fs@~1.2.0: version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" +growl@1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f" + growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" @@ -3214,10 +3201,6 @@ json-stringify-safe@5.0.1, json-stringify-safe@5.0.x, json-stringify-safe@^5.0.1 version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" -json3@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" - json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -3399,21 +3382,10 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -lodash._baseassign@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" - dependencies: - lodash._basecopy "^3.0.0" - lodash.keys "^3.0.0" - lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" -lodash._basecreate@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" - lodash._basetostring@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" @@ -3462,14 +3434,6 @@ lodash.clonedeep@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" -lodash.create@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" - dependencies: - lodash._baseassign "^3.0.0" - lodash._basecreate "^3.0.0" - lodash._isiterateecall "^3.0.0" - lodash.defaults@^4.0.0, lodash.defaults@^4.0.1: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" @@ -3885,22 +3849,20 @@ mobiledoc-dom-renderer@0.6.5: version "0.6.5" resolved "https://registry.yarnpkg.com/mobiledoc-dom-renderer/-/mobiledoc-dom-renderer-0.6.5.tgz#56c0302c4f9c30840ab5b9b20dfe905aed1e437b" -mocha@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d" +mocha@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-4.0.1.tgz#0aee5a95cf69a4618820f5e51fa31717117daf1b" dependencies: browser-stdout "1.3.0" - commander "2.9.0" - debug "2.6.8" - diff "3.2.0" + commander "2.11.0" + debug "3.1.0" + diff "3.3.1" escape-string-regexp "1.0.5" - glob "7.1.1" - growl "1.9.2" + glob "7.1.2" + growl "1.10.3" he "1.1.1" - json3 "3.3.2" - lodash.create "3.1.1" mkdirp "0.5.1" - supports-color "3.1.2" + supports-color "4.4.0" mocha@^2.4.5: version "2.5.3" @@ -5624,11 +5586,11 @@ supports-color@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" -supports-color@3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" +supports-color@4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" dependencies: - has-flag "^1.0.0" + has-flag "^2.0.0" supports-color@^2.0.0: version "2.0.0"