@@ -10,6 +10,11 @@ function getRootMatch(matches) {
10
10
return matches [ matches . length - 1 ] ;
11
11
}
12
12
13
+ afterEach ( function ( ) {
14
+ // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
15
+ PathStore . removeAllChangeListeners ( ) ;
16
+ } ) ;
17
+
13
18
describe ( 'A Routes' , function ( ) {
14
19
15
20
var App = React . createClass ( {
@@ -32,8 +37,6 @@ describe('A Routes', function () {
32
37
33
38
afterEach ( function ( ) {
34
39
React . unmountComponentAtNode ( component . getDOMNode ( ) ) ;
35
- // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
36
- PathStore . removeAllChangeListeners ( ) ;
37
40
} ) ;
38
41
39
42
it ( 'returns an array' , function ( ) {
@@ -60,8 +63,6 @@ describe('A Routes', function () {
60
63
61
64
afterEach ( function ( ) {
62
65
React . unmountComponentAtNode ( component . getDOMNode ( ) ) ;
63
- // For some reason unmountComponentAtNode doesn't call componentWillUnmount :/
64
- PathStore . removeAllChangeListeners ( ) ;
65
66
} ) ;
66
67
67
68
it ( 'returns an array with the correct params' , function ( ) {
@@ -74,4 +75,58 @@ describe('A Routes', function () {
74
75
} ) ;
75
76
} ) ;
76
77
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
+
77
132
} ) ;
0 commit comments