Skip to content

Commit

Permalink
fixed forcefully destroy the app instance test
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jun 5, 2017
1 parent 6308c5f commit 5455fa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,16 @@ class EmberApp {
* @return {Promise<instance>} instance
*/
visitRoute(path, fastbootInfo, bootOptions, result) {
let instance;

return this.buildAppInstance()
.then(appInstance => {
instance = appInstance;
.then(instance => {
result.instance = instance;
registerFastBootInfo(fastbootInfo, instance);

return instance.boot(bootOptions);
})
.then(() => result.instanceBooted = true)
.then(() => instance.visit(path, bootOptions))
.then(() => result.instance.visit(path, bootOptions))
.then(() => fastbootInfo.deferredPromise)
.then(() => instance);
.then(() => result);
}

/**
Expand Down
15 changes: 13 additions & 2 deletions test/fastboot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,18 @@ describe("FastBoot", function() {
distPath: fixture('basic-app')
});

return fastboot.visit('/', { destroyAppInstanceInMs: 5 })
// delaying `visitRoute` to forcefully destroy app instance
let originalVisitRoute = fastboot._app.visitRoute;
fastboot._app.visitRoute = function() {
return originalVisitRoute.apply(this, arguments)
.then(function() {
return new Promise(function(resolve) {
setTimeout(resolve, 2000);
});
});
};

fastboot.visit('/', { destroyAppInstanceInMs: 5 })
.catch((e) => {
expect(e.message).to.equal('App instance was forcefully destroyed in 5ms');
done();
Expand Down Expand Up @@ -349,7 +360,7 @@ describe("FastBoot", function() {
distPath: fixture('boot-time-failing-app')
});

return fastboot.visit('/')
fastboot.visit('/')
.catch((e) => {
expect(e).to.be.an('error');
done();
Expand Down

0 comments on commit 5455fa1

Please sign in to comment.