Skip to content

Commit

Permalink
Ensure Transition#isActive is initially truthy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Jackson committed Sep 12, 2016
1 parent 55d8b78 commit 955dbd4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/router/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function Transition(router, intent, state, error) {
this.targetName = undefined;
this.pivotHandler = undefined;
this.sequence = undefined;
this.isAborted = undefined;
this.isActive = undefined;
this.isAborted = false;
this.isActive = true;

if (error) {
this.promise = Promise.reject(error);
Expand Down Expand Up @@ -89,7 +89,6 @@ Transition.prototype = {
pivotHandler: null,
resolveIndex: 0,
resolvedModels: null,
isActive: true,
state: null,
queryParamsOnly: false,

Expand Down
36 changes: 36 additions & 0 deletions test/tests/router_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2800,6 +2800,42 @@ test("A successful transition calls the finally callback", function(assert) {
});
});

test("transition sets isActive by default", function(assert) {
assert.expect(2);

map(assert, function(match) {
match("/").to("application", function(match) {
match("/example").to("exampleRoute");
});
});


let transition = router.handleURL("/example");

assert.equal(transition.isActive, true);
assert.equal(transition.isAborted, false);
});

test("transition sets isActive to false when aborted", function(assert) {
assert.expect(4);

map(assert, function(match) {
match("/").to("application", function(match) {
match("/example").to("exampleRoute");
});
});

let transition = router.handleURL("/example");

assert.equal(transition.isActive, true, 'precond');
assert.equal(transition.isAborted, false, 'precond');

transition.abort();

assert.equal(transition.isActive, false, 'isActive should be false after abort');
assert.equal(transition.isAborted, true, 'isAborted is set to true after abort');
});

if (scenario.async) {
test('getHandler is invoked synchronously when returning Promises', function(assert) {
assert.expect(2);
Expand Down

0 comments on commit 955dbd4

Please sign in to comment.