Skip to content

Commit 6f7d4b8

Browse files
test(transition): Add test for onError being called due to error in onBefore hook
1 parent 215cafc commit 6f7d4b8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/transitionSpec.ts

+11
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,17 @@ describe('transition', function () {
475475
.then(done);
476476
}));
477477

478+
it('should be called if an onBefore hook fails.', ((done) => {
479+
let states = [];
480+
$transitions.onBefore({ from: "A", entering: "C" }, function() { throw new Error("oops!"); });
481+
$transitions.onError({ }, function(trans) { states.push(trans.to().name); });
482+
483+
Promise.resolve()
484+
.then(goFail("A", "D"))
485+
.then(() => expect(states).toEqual([ 'D' ]))
486+
.then(done);
487+
}));
488+
478489
it('should be called for only handlers matching the transition.', ((done) => {
479490
let hooks = [];
480491
$transitions.onEnter({ from: "A", entering: "C" }, function() { throw new Error("oops!"); });

0 commit comments

Comments
 (0)