|
1 | 1 | /*eslint-env mocha */
|
2 | 2 | /*eslint react/prop-types: 0*/
|
3 |
| -import expect from 'expect' |
| 3 | +import expect, { spyOn } from 'expect' |
4 | 4 | import React, { Component } from 'react'
|
5 |
| -import ReactTestUtils from 'react-addons-test-utils' |
| 5 | +import { Simulate } from 'react-addons-test-utils' |
6 | 6 | import { render } from 'react-dom'
|
7 | 7 | import createHistory from 'history/lib/createMemoryHistory'
|
8 | 8 | import execSteps from './execSteps'
|
9 | 9 | import Router from '../Router'
|
10 | 10 | import Route from '../Route'
|
11 | 11 | import Link from '../Link'
|
12 | 12 |
|
13 |
| -const { click } = ReactTestUtils.Simulate |
| 13 | +const { click } = Simulate |
14 | 14 |
|
15 | 15 | describe('A <Link>', function () {
|
16 | 16 |
|
@@ -289,23 +289,27 @@ describe('A <Link>', function () {
|
289 | 289 | // just here to make sure click handlers don't prevent it from happening
|
290 | 290 | }
|
291 | 291 | render() {
|
292 |
| - return <Link to="/hello" onClick={(e) => this.handleClick(e)}>Link</Link> |
| 292 | + return <Link to="/hello" hash="#world" onClick={(e) => this.handleClick(e)}>Link</Link> |
293 | 293 | }
|
294 | 294 | }
|
295 | 295 |
|
| 296 | + const history = createHistory('/') |
| 297 | + const spy = spyOn(history, 'pushState').andCallThrough() |
| 298 | + |
296 | 299 | const steps = [
|
297 | 300 | function () {
|
298 | 301 | click(node.querySelector('a'), { button: 0 })
|
299 | 302 | },
|
300 | 303 | function () {
|
301 | 304 | expect(node.innerHTML).toMatch(/Hello/)
|
| 305 | + expect(spy).toHaveBeenCalledWith(undefined, '/hello#world') |
302 | 306 | }
|
303 | 307 | ]
|
304 | 308 |
|
305 | 309 | const execNextStep = execSteps(steps, done)
|
306 | 310 |
|
307 | 311 | render((
|
308 |
| - <Router history={createHistory('/')} onUpdate={execNextStep}> |
| 312 | + <Router history={history} onUpdate={execNextStep}> |
309 | 313 | <Route path="/" component={LinkWrapper} />
|
310 | 314 | <Route path="/hello" component={Hello} />
|
311 | 315 | </Router>
|
|
0 commit comments