@@ -10,6 +10,11 @@ function getRootMatch(matches) {
1010 return matches [ matches . length - 1 ] ;
1111}
1212
13+ afterEach ( function ( ) {
14+ // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
15+ PathStore . removeAllChangeListeners ( ) ;
16+ } ) ;
17+
1318describe ( 'A Routes' , function ( ) {
1419
1520 var App = React . createClass ( {
@@ -32,8 +37,6 @@ describe('A Routes', function () {
3237
3338 afterEach ( function ( ) {
3439 React . unmountComponentAtNode ( component . getDOMNode ( ) ) ;
35- // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
36- PathStore . removeAllChangeListeners ( ) ;
3740 } ) ;
3841
3942 it ( 'returns an array' , function ( ) {
@@ -60,8 +63,6 @@ describe('A Routes', function () {
6063
6164 afterEach ( function ( ) {
6265 React . unmountComponentAtNode ( component . getDOMNode ( ) ) ;
63- // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
64- PathStore . removeAllChangeListeners ( ) ;
6566 } ) ;
6667
6768 it ( 'returns an array with the correct params' , function ( ) {
@@ -74,4 +75,58 @@ describe('A Routes', function () {
7475 } ) ;
7576 } ) ;
7677
78+
79+ describe ( 'when a transition is aborted' , function ( ) {
80+ it ( 'triggers onAbortedTransition' , function ( done ) {
81+ var App = React . createClass ( {
82+ statics : {
83+ willTransitionTo : function ( transition ) {
84+ transition . abort ( ) ;
85+ }
86+ } ,
87+ render : function ( ) {
88+ return React . DOM . div ( ) ;
89+ }
90+ } ) ;
91+
92+ function handleAbortedTransition ( transition ) {
93+ assert ( transition ) ;
94+ done ( ) ;
95+ }
96+
97+ ReactTestUtils . renderIntoDocument (
98+ Routes ( { onAbortedTransition : handleAbortedTransition } ,
99+ Route ( { handler : App } )
100+ )
101+ ) ;
102+ } ) ;
103+ } ) ;
104+
105+ describe ( 'when there is an error in a transition hook' , function ( ) {
106+ it ( 'triggers onTransitionError' , function ( done ) {
107+ var App = React . createClass ( {
108+ statics : {
109+ willTransitionTo : function ( transition ) {
110+ throw new Error ( 'boom!' ) ;
111+ }
112+ } ,
113+ render : function ( ) {
114+ return React . DOM . div ( ) ;
115+ }
116+ } ) ;
117+
118+ function handleTransitionError ( error ) {
119+ assert ( error ) ;
120+ expect ( error . message ) . toEqual ( 'boom!' ) ;
121+ done ( ) ;
122+ }
123+
124+ ReactTestUtils . renderIntoDocument (
125+ Routes ( { onTransitionError : handleTransitionError } ,
126+ Route ( { handler : App } )
127+ )
128+ ) ;
129+ } ) ;
130+ } ) ;
131+
77132} ) ;
0 commit comments