Skip to content

Commit 76492a3

Browse files
committed
clean up some test stuff
1 parent f02b919 commit 76492a3

File tree

2 files changed

+11
-91
lines changed

2 files changed

+11
-91
lines changed

modules/__tests__/Link-test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ describe('Link', () => {
2828
getChildContext() {
2929
return {
3030
router: {
31-
createHref: () => CONTEXT_HREF
31+
createHref: () => CONTEXT_HREF,
32+
blockTransitions: () => {},
33+
transitionTo: () => {},
34+
replaceWith: () => {}
3235
}
3336
}
3437
}
@@ -254,7 +257,13 @@ describe('Link', () => {
254257
class TestRouterContext extends React.Component {
255258
static childContextTypes = { location: PropTypes.object }
256259
getChildContext() {
257-
return { location: { pathname: PATHNAME } }
260+
return {
261+
location: {
262+
pathname: PATHNAME,
263+
search: '',
264+
hash: ''
265+
}
266+
}
258267
}
259268
render() { return this.props.children }
260269
}

modules/__tests__/StaticRouter-test.js

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -189,93 +189,4 @@ describe('StaticRouter', () => {
189189

190190
})
191191
})
192-
193-
// TODO: maybe these tests just move to Link, Redirect, and NavigationPrompt,
194-
// or like "integration-test.js"
195-
describe.skip('context', () => {
196-
describe('createHref', () => {
197-
it('creates hrefs', () => {
198-
const markup = renderToString(
199-
<StaticRouter location="/">
200-
<Link to="/somewhere"/>
201-
</StaticRouter>
202-
)
203-
expect(markup).toMatch(/\/somewhere/)
204-
})
205-
206-
it('uses createHref prop', () => {
207-
const markup = renderToString(
208-
<StaticRouter location="/" createHref={(href) => '#'+href}>
209-
<Link to="/somewhere"/>
210-
</StaticRouter>
211-
)
212-
expect(markup).toMatch(/#\/somewhere/)
213-
})
214-
})
215-
216-
describe('push', () => {
217-
it('calls onPush', (done) => {
218-
const assert = (location) => {
219-
expect(location).toExist()
220-
expect(location.pathname).toEqual('/somewhere')
221-
done()
222-
}
223-
renderToString(
224-
<StaticRouter location="/" onPush={assert}>
225-
{({ location }) => (
226-
location.pathname === "/" ? (
227-
<Redirect to="/somewhere" push/>
228-
) : (
229-
<div>test</div>
230-
)
231-
)}
232-
</StaticRouter>
233-
)
234-
})
235-
})
236-
237-
describe('replace', () => {
238-
239-
it('calls onReplace', (done) => {
240-
const assert = (location) => {
241-
expect(location).toExist()
242-
expect(location.pathname).toEqual('/somewhere')
243-
done()
244-
}
245-
renderToString(
246-
<StaticRouter location="/" onPush={assert}>
247-
{({ location }) => (
248-
location.pathname === "/" ? (
249-
<Redirect to="/somewhere" push={false}/>
250-
) : (
251-
<div>test</div>
252-
)
253-
)}
254-
</StaticRouter>
255-
)
256-
})
257-
})
258-
259-
describe('block', () => {
260-
it('calls onBlock', (done) => {
261-
const assert = (location) => {
262-
expect(location).toExist()
263-
expect(location.pathname).toEqual('/somewhere')
264-
done()
265-
}
266-
renderToString(
267-
<StaticRouter location="/" onPush={assert}>
268-
{({ location }) => (
269-
location.pathname === "/" ? (
270-
<Redirect to="/somewhere" replace/>
271-
) : (
272-
<div>test</div>
273-
)
274-
)}
275-
</StaticRouter>
276-
)
277-
})
278-
})
279-
})
280-
281192
})

0 commit comments

Comments
 (0)