Skip to content

Commit 65f76f1

Browse files
committed
Added lazy-state definition test.
1 parent 47d4464 commit 65f76f1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/stateSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ describe('state', function () {
194194
expect($state.params).toEqual({ x: '1', y: '2' });
195195
}));
196196

197+
it('can lazy-define a state in $stateNotFound', inject(function ($state, $q, $rootScope) {
198+
initStateTo(DD, { x: 1, y: 2, z: 3 });
199+
var called;
200+
$rootScope.$on('$stateNotFound', function (ev, redirect) {
201+
stateProvider.state(redirect.to, { parent: DD, params: [ 'x', 'y', 'z', 'w' ]});
202+
called = true;
203+
});
204+
var promise = $state.go('DDD', { w: 4 });
205+
$q.flush();
206+
expect(called).toBeTruthy();
207+
expect($state.current.name).toEqual('DDD');
208+
expect($state.params).toEqual({ x: '1', y: '2', z: '3', w: '4' });
209+
}));
210+
197211
it('triggers $stateChangeSuccess', inject(function ($state, $q, $rootScope) {
198212
initStateTo(E, { i: 'iii' });
199213
var called;

0 commit comments

Comments
 (0)