@@ -9,9 +9,9 @@ var App = React.createClass({
9
9
}
10
10
} ) ;
11
11
12
- describe ( 'a Route that matches the URL' , function ( ) {
12
+ describe ( 'a Route that matches a URL' , function ( ) {
13
13
it ( 'returns an array' , function ( ) {
14
- var routes = TestUtils . renderIntoDocument (
14
+ var routes = renderComponent (
15
15
Routes ( null ,
16
16
Route ( { handler : App } ,
17
17
Route ( { path : '/a/b/c' , handler : App } )
@@ -25,11 +25,13 @@ describe('a Route that matches the URL', function () {
25
25
26
26
var rootMatch = getRootMatch ( matches ) ;
27
27
expect ( rootMatch . params ) . toEqual ( { } ) ;
28
+
29
+ removeComponent ( routes ) ;
28
30
} ) ;
29
31
30
32
describe ( 'that contains dynamic segments' , function ( ) {
31
33
it ( 'returns an array with the correct params' , function ( ) {
32
- var routes = TestUtils . renderIntoDocument (
34
+ var routes = renderComponent (
33
35
Routes ( null ,
34
36
Route ( { handler : App } ,
35
37
Route ( { path : '/posts/:id/edit' , handler : App } )
@@ -43,13 +45,15 @@ describe('a Route that matches the URL', function () {
43
45
44
46
var rootMatch = getRootMatch ( matches ) ;
45
47
expect ( rootMatch . params ) . toEqual ( { id : 'abc' } ) ;
48
+
49
+ removeComponent ( routes ) ;
46
50
} ) ;
47
51
} ) ;
48
52
} ) ;
49
53
50
54
describe ( 'a Route that does not match the URL' , function ( ) {
51
55
it ( 'returns null' , function ( ) {
52
- var routes = TestUtils . renderIntoDocument (
56
+ var routes = renderComponent (
53
57
Routes ( null ,
54
58
Route ( { handler : App } ,
55
59
Route ( { path : '/a/b/c' , handler : App } )
@@ -58,12 +62,14 @@ describe('a Route that does not match the URL', function () {
58
62
) ;
59
63
60
64
expect ( routes . match ( '/not-found' ) ) . toBe ( null ) ;
65
+
66
+ removeComponent ( routes ) ;
61
67
} ) ;
62
68
} ) ;
63
69
64
70
describe ( 'a nested Route that matches the URL' , function ( ) {
65
71
it ( 'returns the appropriate params for each match' , function ( ) {
66
- var routes = TestUtils . renderIntoDocument (
72
+ var routes = renderComponent (
67
73
Routes ( null ,
68
74
Route ( { handler : App } ,
69
75
Route ( { name : 'posts' , path : '/posts/:id' , handler : App } ,
@@ -84,12 +90,14 @@ describe('a nested Route that matches the URL', function () {
84
90
var postsMatch = matches [ 1 ] ;
85
91
expect ( postsMatch . route . props . name ) . toEqual ( 'posts' ) ;
86
92
expect ( postsMatch . params ) . toEqual ( { id : 'abc' } ) ;
93
+
94
+ removeComponent ( routes ) ;
87
95
} ) ;
88
96
} ) ;
89
97
90
98
describe ( 'multiple nested Router that match the URL' , function ( ) {
91
99
it ( 'returns the first one in the subtree, depth-first' , function ( ) {
92
- var routes = TestUtils . renderIntoDocument (
100
+ var routes = renderComponent (
93
101
Routes ( null ,
94
102
Route ( { handler : App } ,
95
103
Route ( { path : '/a' , handler : App } ,
@@ -106,52 +114,8 @@ describe('multiple nested Router that match the URL', function () {
106
114
107
115
var rootMatch = getRootMatch ( matches ) ;
108
116
expect ( rootMatch . route . props . name ) . toEqual ( 'expected' ) ;
109
- } ) ;
110
- } ) ;
111
-
112
- describe ( 'a route handler' , function ( ) {
113
- it ( 'may not receive children' , function ( done ) {
114
- var InvalidHandler = React . createClass ( {
115
- displayName : 'InvalidHandler' ,
116
- render : function ( ) {
117
- try {
118
- var result = this . props . activeRouteHandler ( { } , React . DOM . div ( ) ) ;
119
- assert ( false , 'activeRouteHandler rendered with children' ) ;
120
- return result ;
121
- } catch ( error ) {
122
- assert ( error ) ;
123
- }
124
-
125
- done ( ) ;
126
- }
127
- } ) ;
128
-
129
- var routes = TestUtils . renderIntoDocument (
130
- Routes ( null ,
131
- Route ( { handler : InvalidHandler } ,
132
- Route ( { path : '/home' , handler : App } )
133
- )
134
- )
135
- ) ;
136
-
137
- routes . dispatch ( '/home' ) ;
138
- } ) ;
139
- } ) ;
140
-
141
- describe ( 'a Route' , function ( ) {
142
- it ( 'requires a handler' ) ;
143
- } ) ;
144
-
145
- describe ( 'a child route' , function ( ) {
146
- describe ( 'path' , function ( ) {
147
- it ( 'defaults to /' ) ;
148
- it ( 'is not required to start with /' ) ;
149
- it ( 'can be inferred from its name' ) ;
150
- it ( 'must contain all dynamic segments of its parent route path' ) ;
151
- } ) ;
152
117
153
- describe ( 'name' , function ( ) {
154
- it ( 'cannot be reused' ) ;
118
+ removeComponent ( routes ) ;
155
119
} ) ;
156
120
} ) ;
157
121
0 commit comments