Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/__tests__/matchRoutes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import Route from '../Route'

import assert from 'assert'
import expect from 'expect'
import { createLocation } from 'history'
import { createMemoryHistory } from 'history'
import { createRoutes } from '../RouteUtils'
import matchRoutes from '../matchRoutes'

describe('matchRoutes', function () {

let routes, RootRoute, UsersRoute, UsersIndexRoute, UserRoute, PostRoute, FilesRoute, AboutRoute, TeamRoute, ProfileRoute, CatchAllRoute
let createLocation = createMemoryHistory().createLocation
beforeEach(function () {
/*
<Route>
Expand Down
28 changes: 16 additions & 12 deletions modules/__tests__/serverRendering-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*eslint react/prop-types: 0*/
import expect from 'expect'
import React from 'react'
import createLocation from 'history/lib/createLocation'
import createMemoryHistory from 'history/lib/createMemoryHistory'
import RoutingContext from '../RoutingContext'
import match from '../match'
import Link from '../Link'
Expand Down Expand Up @@ -71,8 +71,9 @@ describe('server rendering', function () {
})

it('works', function (done) {
const location = createLocation('/dashboard')
match({ routes, location }, function (error, redirectLocation, renderProps) {
const history = createMemoryHistory()
const location = history.createLocation('/dashboard')
match({ routes, history, location }, function (error, redirectLocation, renderProps) {
const string = React.renderToString(
<RoutingContext {...renderProps} />
)
Expand All @@ -82,8 +83,9 @@ describe('server rendering', function () {
})

it('renders active Links as active', function (done) {
const location = createLocation('/about')
match({ routes, location }, function (error, redirectLocation, renderProps) {
const history = createMemoryHistory()
const location = history.createLocation('/about')
match({ routes, history, location }, function (error, redirectLocation, renderProps) {
const string = React.renderToString(
<RoutingContext {...renderProps} />
)
Expand All @@ -94,8 +96,9 @@ describe('server rendering', function () {
})

it('sends the redirect location', function (done) {
const location = createLocation('/company')
match({ routes, location }, function (error, redirectLocation) {
const history = createMemoryHistory()
const location = history.createLocation('/company')
match({ routes, history, location }, function (error, redirectLocation) {
expect(redirectLocation).toExist()
expect(redirectLocation.pathname).toEqual('/about')
expect(redirectLocation.search).toEqual('')
Expand All @@ -106,11 +109,12 @@ describe('server rendering', function () {
})

it('sends null values when no routes match', function (done) {
const location = createLocation('/no-match')
match({ routes, location }, function (error, redirectLocation, state) {
expect(error).toBe(null)
expect(redirectLocation).toBe(null)
expect(state).toBe(null)
const history = createMemoryHistory()
const location = history.createLocation('/no-match')
match({ routes, history, location }, function (error, redirectLocation, state) {
expect(error).toNotExist()
expect(redirectLocation).toNotExist()
expect(state).toNotExist()
done()
})
})
Expand Down
5 changes: 2 additions & 3 deletions modules/useRoutes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import warning from 'warning'
import { REPLACE } from 'history/lib/Actions'
import useQueries from 'history/lib/useQueries'
import createLocation from 'history/lib/createLocation'
import computeChangedRoutes from './computeChangedRoutes'
import { runEnterHooks, runLeaveHooks } from './TransitionUtils'
import { default as _isActive } from './isActive'
Expand Down Expand Up @@ -55,7 +54,7 @@ function useRoutes(createHistory) {
}

function createLocationFromRedirectInfo({ pathname, query, state }) {
return createLocation(
return history.createLocation(
history.createPath(pathname, query), state, REPLACE, history.createKey()
)
}
Expand Down Expand Up @@ -181,7 +180,7 @@ function useRoutes(createHistory) {
} else if (hooks.indexOf(hook) === -1) {
hooks.push(hook)
}

return function () {
let hooks = RouteHooks[routeID]

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"license": "MIT",
"dependencies": {
"history": "^1.11.0",
"history": "^1.12.0",
"invariant": "^2.0.0",
"warning": "^2.0.0"
},
Expand Down