Skip to content

Commit 3f78850

Browse files
chore(stateSpec): merge test for #2772
1 parent 6aabc45 commit 3f78850

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/ng1/stateSpec.js

+31
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,37 @@ describe('.onInvalid()', function() {
18381838
}));
18391839
});
18401840

1841+
describe('exceptions in onEnter', function() {
1842+
beforeEach(module(function ($stateProvider, $exceptionHandlerProvider) {
1843+
$exceptionHandlerProvider.mode('log');
1844+
$stateProvider
1845+
.state('A', { })
1846+
.state('onEnterFail', {
1847+
onEnter: function() {
1848+
throw new Error('negative onEnter');
1849+
}
1850+
});
1851+
}));
1852+
1853+
// Test for #2772
1854+
it('trigger transition.onError', inject(function ($state, $q, $transitions) {
1855+
var called;
1856+
$transitions.defaultErrorHandler(function() { });
1857+
$transitions.onError({}, function($error$) {
1858+
called = true;
1859+
});
1860+
1861+
$state.go('A'); $q.flush();
1862+
expect($state.current.name).toEqual('A');
1863+
1864+
$state.transitionTo('onEnterFail');
1865+
$q.flush();
1866+
1867+
expect(called).toBeTruthy();
1868+
expect($state.current.name).toEqual('A');
1869+
}))
1870+
});
1871+
18411872
describe('$stateParams', function () {
18421873
beforeEach(module('ui.router.state'));
18431874

0 commit comments

Comments
 (0)