From e89a60c45c59c05e18db87bd54aa452b276ba8aa Mon Sep 17 00:00:00 2001 From: Simon Ho Date: Fri, 20 Feb 2015 13:50:41 -0800 Subject: [PATCH] Add unit test to verify `app.booting flag status - Ensure `app.booting` is initially `undefined` - Ensure `app.booting` is set to true during boot execution - Ensure `app.booting` is set to false upon boot completion --- test/executor.test.js | 7 ++++--- test/fixtures/simple-app/boot/booting.js | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/simple-app/boot/booting.js diff --git a/test/executor.test.js b/test/executor.test.js index bd17481..46513f0 100644 --- a/test/executor.test.js +++ b/test/executor.test.js @@ -53,11 +53,12 @@ describe('executor', function() { }); describe('when booting', function() { - it('should set the booting status', function(done) { + it('should set the `booting` flag during execution', function(done) { expect(app.booting).to.be.undefined(); - boot.execute(app, dummyInstructions, function(err) { + boot.execute(app, simpleAppInstructions(), function(err) { expect(err).to.be.undefined(); - expect(app.booting).to.be.false(); + expect(process.bootingFlagSet).to.be.ok(); + expect(app.booting).to.not.be.ok(); done(); }); }); diff --git a/test/fixtures/simple-app/boot/booting.js b/test/fixtures/simple-app/boot/booting.js new file mode 100644 index 0000000..b7ec8b8 --- /dev/null +++ b/test/fixtures/simple-app/boot/booting.js @@ -0,0 +1,6 @@ +module.exports = function(app, cb) { + if (app.booting) + process.bootingFlagSet = true; + + process.nextTick(cb); +};