@@ -79,6 +79,40 @@ describe('ReactErrorBoundaries', function() {
79
79
expect ( EventPluginHub . putListener ) . toBeCalled ( ) ;
80
80
} ) ;
81
81
82
+ it ( 'correctly handles composite siblings' , function ( ) {
83
+ class ErrorBoundary extends React . Component {
84
+ constructor ( ) {
85
+ super ( ) ;
86
+ this . state = { error : false } ;
87
+ }
88
+
89
+ render ( ) {
90
+ if ( ! this . state . error ) {
91
+ return < div > { this . props . children } </ div > ;
92
+ }
93
+ return < div > Error has been caught</ div > ;
94
+ }
95
+
96
+ unstable_handleError ( ) {
97
+ this . setState ( { error : true } ) ;
98
+ }
99
+ }
100
+
101
+ function Broken ( ) {
102
+ throw new Error ( 'Always broken.' ) ;
103
+ }
104
+
105
+ function Composite ( ) {
106
+ return < div /> ;
107
+ }
108
+
109
+ var container = document . createElement ( 'div' ) ;
110
+ ReactDOM . render (
111
+ < ErrorBoundary > < Broken /> < Composite /> </ ErrorBoundary > ,
112
+ container
113
+ ) ;
114
+ ReactDOM . unmountComponentAtNode ( container ) ;
115
+ } ) ;
82
116
83
117
it ( 'catches errors from children' , function ( ) {
84
118
var log = [ ] ;
@@ -144,15 +178,16 @@ describe('ReactErrorBoundaries', function() {
144
178
var container = document . createElement ( 'div' ) ;
145
179
ReactDOM . render ( < Box /> , container ) ;
146
180
expect ( container . textContent ) . toBe ( 'Error: Please, do not render me.' ) ;
181
+ ReactDOM . unmountComponentAtNode ( container ) ;
147
182
expect ( log ) . toEqual ( [
148
183
'Box render' ,
149
184
'Inquisitive render' ,
150
185
'Angry render' ,
151
186
'Inquisitive ref null' ,
152
187
'Inquisitive componentWillUnmount' ,
153
- 'Angry componentWillUnmount' ,
154
188
'Box renderError' ,
155
189
'Box componentDidMount' ,
190
+ 'Box componentWillUnmount' ,
156
191
] ) ;
157
192
} ) ;
158
193
} ) ;
0 commit comments