1
1
import React , { Component , PropTypes } from 'react' ;
2
+ import ReactDOM from 'react-dom' ;
2
3
import { assert } from 'chai' ;
3
4
import sinon from 'sinon' ;
4
5
import window from 'window' ;
@@ -19,7 +20,7 @@ describe('Switcher', function() {
19
20
describe ( '#getLocation' , function ( ) {
20
21
describe ( 'using location.hash' , function ( ) {
21
22
beforeEach ( function ( ) {
22
- this . switcher = React . render (
23
+ this . switcher = ReactDOM . render (
23
24
< Switcher >
24
25
< div path = "/" > Home</ div >
25
26
< div path = "/another" > Another</ div >
@@ -53,7 +54,7 @@ describe('Switcher', function() {
53
54
54
55
describe ( 'using location.pathname' , function ( ) {
55
56
beforeEach ( function ( ) {
56
- this . switcher = React . render (
57
+ this . switcher = ReactDOM . render (
57
58
< Switcher location = "pathname" >
58
59
< div path = "/" > Home</ div >
59
60
< div path = "/another" > Another</ div >
@@ -89,7 +90,7 @@ describe('Switcher', function() {
89
90
describe ( '#getSwitch' , function ( ) {
90
91
describe ( 'default' , function ( ) {
91
92
beforeEach ( function ( ) {
92
- this . switcher = React . render (
93
+ this . switcher = ReactDOM . render (
93
94
< Switcher >
94
95
< div path = "/" > Home</ div >
95
96
< div path = "/another" > Another</ div >
@@ -151,7 +152,7 @@ describe('Switcher', function() {
151
152
152
153
describe ( 'with basepath set' , function ( ) {
153
154
beforeEach ( function ( ) {
154
- this . switcher = React . render (
155
+ this . switcher = ReactDOM . render (
155
156
< Switcher basePath = "/base" >
156
157
< div path = "/" > Home</ div >
157
158
< div path = "/another" > Another</ div >
@@ -176,7 +177,7 @@ describe('Switcher', function() {
176
177
describe ( '#handleRouteChange' , function ( ) {
177
178
describe ( 'default' , function ( ) {
178
179
beforeEach ( function ( ) {
179
- this . switcher = React . render (
180
+ this . switcher = ReactDOM . render (
180
181
< Switcher >
181
182
< div path = "/" > Home</ div >
182
183
</ Switcher > ,
@@ -200,7 +201,7 @@ describe('Switcher', function() {
200
201
describe ( 'with onChange function defined' , function ( ) {
201
202
beforeEach ( function ( ) {
202
203
this . handleChange = sinon . spy ( ) ;
203
- this . switcher = React . render (
204
+ this . switcher = ReactDOM . render (
204
205
< Switcher onChange = { this . handleChange } >
205
206
< div path = "/" > Home</ div >
206
207
</ Switcher > ,
@@ -222,7 +223,7 @@ describe('Switcher', function() {
222
223
describe ( '#render' , function ( ) {
223
224
describe ( 'default' , function ( ) {
224
225
beforeEach ( function ( ) {
225
- this . switcher = React . render (
226
+ this . switcher = ReactDOM . render (
226
227
< Switcher >
227
228
< div path = "/" > Home</ div >
228
229
</ Switcher > ,
@@ -237,22 +238,22 @@ describe('Switcher', function() {
237
238
it ( 'renders nothing if no match' , function ( ) {
238
239
window . location . hash = '/nomatch' ;
239
240
this . switcher . handleRouteChange ( ) ;
240
- var node = React . findDOMNode ( this . switcher ) ;
241
+ var node = ReactDOM . findDOMNode ( this . switcher ) ;
241
242
assert . isNull ( node ) ;
242
243
} ) ;
243
244
244
245
it ( 'renders matching component' , function ( ) {
245
246
window . location . hash = '/' ;
246
247
this . switcher . handleRouteChange ( ) ;
247
- var node = React . findDOMNode ( this . switcher ) ;
248
+ var node = ReactDOM . findDOMNode ( this . switcher ) ;
248
249
assert . equal ( node . innerHTML , 'Home' ) ;
249
250
} ) ;
250
251
} ) ;
251
252
252
253
describe ( 'with default handler' , function ( ) {
253
254
beforeEach ( function ( ) {
254
255
var props = { text : 'Hello' } ;
255
- this . switcher = React . render (
256
+ this . switcher = ReactDOM . render (
256
257
< Switcher
257
258
defaultHandler = { Handler }
258
259
defaultHandlerProps = { props } >
@@ -269,21 +270,21 @@ describe('Switcher', function() {
269
270
it ( 'renders default handler when no match' , function ( ) {
270
271
window . location . hash = '/nomatch' ;
271
272
this . switcher . handleRouteChange ( ) ;
272
- var node = React . findDOMNode ( this . switcher ) ;
273
+ var node = ReactDOM . findDOMNode ( this . switcher ) ;
273
274
assert . equal ( node . innerHTML , 'Hello' ) ;
274
275
} ) ;
275
276
276
277
it ( 'renders matching component' , function ( ) {
277
278
window . location . hash = '/' ;
278
279
this . switcher . handleRouteChange ( ) ;
279
- var node = React . findDOMNode ( this . switcher ) ;
280
+ var node = ReactDOM . findDOMNode ( this . switcher ) ;
280
281
assert . equal ( node . innerHTML , 'Home' ) ;
281
282
} ) ;
282
283
} ) ;
283
284
284
285
describe ( 'with wrapper' , function ( ) {
285
286
beforeEach ( function ( ) {
286
- this . switcher = React . render (
287
+ this . switcher = ReactDOM . render (
287
288
< Switcher wrapper = "span" >
288
289
< div path = "/" > Home</ div >
289
290
</ Switcher > ,
@@ -298,15 +299,15 @@ describe('Switcher', function() {
298
299
it ( 'renders just wrapper when no match' , function ( ) {
299
300
window . location . hash = '/nomatch' ;
300
301
this . switcher . handleRouteChange ( ) ;
301
- var wrapper = React . findDOMNode ( this . switcher ) ;
302
+ var wrapper = ReactDOM . findDOMNode ( this . switcher ) ;
302
303
assert . equal ( wrapper . innerHTML , '' ) ;
303
304
assert . equal ( wrapper . tagName , 'SPAN' ) ;
304
305
} ) ;
305
306
306
307
it ( 'renders matched component in wrapper' , function ( ) {
307
308
window . location . hash = '/' ;
308
309
this . switcher . handleRouteChange ( ) ;
309
- var wrapper = React . findDOMNode ( this . switcher ) ;
310
+ var wrapper = ReactDOM . findDOMNode ( this . switcher ) ;
310
311
var component = wrapper . children [ 0 ] ;
311
312
assert . equal ( wrapper . tagName , 'SPAN' ) ;
312
313
assert . equal ( component . innerHTML , 'Home' ) ;
0 commit comments