File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1838,6 +1838,37 @@ describe('.onInvalid()', function() {
1838
1838
} ) ) ;
1839
1839
} ) ;
1840
1840
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
+
1841
1872
describe ( '$stateParams' , function ( ) {
1842
1873
beforeEach ( module ( 'ui.router.state' ) ) ;
1843
1874
You can’t perform that action at this time.
0 commit comments