From 00926244fe521b9804b08792e947e13205d6f339 Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Fri, 17 Jun 2016 16:14:44 +0100 Subject: [PATCH] Add tests for async/non-async items --- test/data/fake/database.js | 4 +--- test/data/fake/endpoints.js | 7 +++++++ test/lib/up.test.js | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 test/data/fake/endpoints.js diff --git a/test/data/fake/database.js b/test/data/fake/database.js index f72a339..8de4b5e 100644 --- a/test/data/fake/database.js +++ b/test/data/fake/database.js @@ -1,5 +1,3 @@ -module.exports = function database (next) { +module.exports = function database () { global.database = true - - return next() } \ No newline at end of file diff --git a/test/data/fake/endpoints.js b/test/data/fake/endpoints.js new file mode 100644 index 0000000..c29a129 --- /dev/null +++ b/test/data/fake/endpoints.js @@ -0,0 +1,7 @@ +module.exports = function endpoints (next) { + setTimeout(function () { + global.endpoints = true + + return next() + }, 50) +} \ No newline at end of file diff --git a/test/lib/up.test.js b/test/lib/up.test.js index b91484c..19e77ea 100644 --- a/test/lib/up.test.js +++ b/test/lib/up.test.js @@ -3,6 +3,7 @@ var up = require('../../lib/up') describe('microboot/lib/up', function () { beforeEach(function () { global.database = false + global.endpoints = false global.end1 = false global.end2 = false global.end3 = false @@ -40,9 +41,12 @@ describe('microboot/lib/up', function () { expect(up.bind(up, ['test/data/fake', 'na'])).to.throw('no such file or directory') }) - it('should run database phase', function (done) { + it('should run database and endpoints phase', function (done) { + this.slow(200) + up(['test/data/fake'], function () { expect(global.database).to.equal(true) + expect(global.endpoints).to.equal(true) done() })