forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransitionTo-test.js
More file actions
56 lines (48 loc) · 1.38 KB
/
transitionTo-test.js
File metadata and controls
56 lines (48 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import expect from 'expect';
import React from 'react';
import createHistory from 'history/lib/createHashHistory';
import resetHash from './resetHash';
import execSteps from './execSteps';
import Router from '../Router';
import Route from '../Route';
describe('transitionTo', function () {
beforeEach(resetHash);
var node;
beforeEach(function () {
node = document.createElement('div');
});
afterEach(function () {
React.unmountComponentAtNode(node);
});
describe('when the target path contains a colon', function () {
it('works', function (done) {
var Index = React.createClass({
render() {
return <h1>Index</h1>;
}
});
var Home = React.createClass({
render() {
return <h1>Home</h1>;
}
});
var steps = [
function () {
expect(this.state.location.pathname).toEqual('/');
this.transitionTo('/home/hi:there');
},
function () {
expect(this.state.location.pathname).toEqual('/home/hi:there');
}
];
var execNextStep = execSteps(steps, done);
var history = createHistory();
React.render((
<Router history={history} onUpdate={execNextStep}>
<Route path="/" component={Index}/>
<Route path="/home/hi:there" component={Home}/>
</Router>
), node, execNextStep);
});
});
});