Skip to content

Commit baf79b6

Browse files
committedJul 21, 2014
[fixed] Avoid some warnings
1 parent 31e0597 commit baf79b6

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed
 

‎specs/Route.spec.js

+40-20
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,31 @@ var App = React.createClass({
1010

1111
describe('a Route that matches the URL', function () {
1212
it('returns an array', function () {
13-
var route = Route({ path: '/a/b/c', handler: App });
13+
var route = TestUtils.renderIntoDocument(
14+
Route({ handler: App },
15+
Route({ path: '/a/b/c', handler: App })
16+
)
17+
);
1418

1519
var matches = route.match('/a/b/c');
1620
assert(matches);
17-
expect(matches.length).toEqual(1);
21+
expect(matches.length).toEqual(2);
1822

1923
var rootMatch = getRootMatch(matches);
2024
expect(rootMatch.params).toEqual({});
2125
});
2226

2327
describe('that contains dynamic segments', function () {
2428
it('returns an array with the correct params', function () {
25-
var route = Route({ path: '/posts/:id/edit', handler: App });
29+
var route = TestUtils.renderIntoDocument(
30+
Route({ handler: App },
31+
Route({ path: '/posts/:id/edit', handler: App })
32+
)
33+
);
2634

2735
var matches = route.match('/posts/abc/edit');
2836
assert(matches);
29-
expect(matches.length).toEqual(1);
37+
expect(matches.length).toEqual(2);
3038

3139
var rootMatch = getRootMatch(matches);
3240
expect(rootMatch.params).toEqual({ id: 'abc' });
@@ -36,38 +44,49 @@ describe('a Route that matches the URL', function () {
3644

3745
describe('a Route that does not match the URL', function () {
3846
it('returns null', function () {
39-
var route = Route({ path: '/a/b/c', handler: App });
47+
var route = TestUtils.renderIntoDocument(
48+
Route({ handler: App },
49+
Route({ path: '/a/b/c', handler: App })
50+
)
51+
);
52+
4053
expect(route.match('/not-found')).toBe(null);
4154
});
4255
});
4356

4457
describe('a nested Route that matches the URL', function () {
4558
it('returns the appropriate params for each match', function () {
46-
var route = Route({ name: 'posts', path: '/posts/:id', handler: App },
47-
Route({ name: 'comment', path: '/posts/:id/comments/:commentId', handler: App })
59+
var route = TestUtils.renderIntoDocument(
60+
Route({ handler: App },
61+
Route({ name: 'posts', path: '/posts/:id', handler: App },
62+
Route({ name: 'comment', path: '/posts/:id/comments/:commentId', handler: App })
63+
)
64+
)
4865
);
4966

5067
var matches = route.match('/posts/abc/comments/123');
5168
assert(matches);
52-
expect(matches.length).toEqual(2);
69+
expect(matches.length).toEqual(3);
5370

5471
var rootMatch = getRootMatch(matches);
5572
expect(rootMatch.route.props.name).toEqual('comment');
5673
expect(rootMatch.params).toEqual({ id: 'abc', commentId: '123' });
5774

58-
var firstMatch = matches[0];
59-
expect(firstMatch.route.props.name).toEqual('posts');
60-
expect(firstMatch.params).toEqual({ id: 'abc' });
75+
var postsMatch = matches[1];
76+
expect(postsMatch.route.props.name).toEqual('posts');
77+
expect(postsMatch.params).toEqual({ id: 'abc' });
6178
});
6279
});
6380

6481
describe('multiple nested Router that match the URL', function () {
6582
it('returns the first one in the subtree, depth-first', function () {
66-
var route = Route({ path: '/', handler: App },
67-
Route({ path: '/a', handler: App },
68-
Route({ path: '/a/b', name: 'expected', handler: App })
69-
),
70-
Route({ path: '/a/b', handler: App })
83+
var route = TestUtils.renderIntoDocument(
84+
Route({ handler: App },
85+
Route({ path: '/a', handler: App },
86+
Route({ path: '/a/b', name: 'expected', handler: App })
87+
),
88+
Route({ path: '/a/b', handler: App })
89+
)
7190
);
7291

7392
var matches = route.match('/a/b');
@@ -81,12 +100,13 @@ describe('multiple nested Router that match the URL', function () {
81100

82101
describe('a Route with custom props', function() {
83102
it('receives props', function (done) {
84-
var route = Route({ handler: App, customProp: 'prop' });
85-
var component = TestUtils.renderIntoDocument(route);
103+
var route = TestUtils.renderIntoDocument(
104+
Route({ handler: App, customProp: 'prop' })
105+
);
86106

87107
route.dispatch('/').then(function () {
88-
assert(component.props.customProp);
89-
expect(component.props.customProp).toEqual('prop');
108+
assert(route.props.customProp);
109+
expect(route.props.customProp).toEqual('prop');
90110
done();
91111
});
92112
});

0 commit comments

Comments
 (0)
Please sign in to comment.