22/*eslint react/prop-types: 0*/
33import expect from 'expect'
44import React from 'react'
5- import createLocation from 'history/lib/createLocation '
5+ import createMemoryHistory from 'history/lib/createMemoryHistory '
66import RoutingContext from '../RoutingContext'
77import match from '../match'
88import Link from '../Link'
@@ -71,8 +71,9 @@ describe('server rendering', function () {
7171 } )
7272
7373 it ( 'works' , function ( done ) {
74- const location = createLocation ( '/dashboard' )
75- match ( { routes, location } , function ( error , redirectLocation , renderProps ) {
74+ const history = createMemoryHistory ( )
75+ const location = history . createLocation ( '/dashboard' )
76+ match ( { routes, history, location } , function ( error , redirectLocation , renderProps ) {
7677 const string = React . renderToString (
7778 < RoutingContext { ...renderProps } />
7879 )
@@ -82,8 +83,9 @@ describe('server rendering', function () {
8283 } )
8384
8485 it ( 'renders active Links as active' , function ( done ) {
85- const location = createLocation ( '/about' )
86- match ( { routes, location } , function ( error , redirectLocation , renderProps ) {
86+ const history = createMemoryHistory ( )
87+ const location = history . createLocation ( '/about' )
88+ match ( { routes, history, location } , function ( error , redirectLocation , renderProps ) {
8789 const string = React . renderToString (
8890 < RoutingContext { ...renderProps } />
8991 )
@@ -94,8 +96,9 @@ describe('server rendering', function () {
9496 } )
9597
9698 it ( 'sends the redirect location' , function ( done ) {
97- const location = createLocation ( '/company' )
98- match ( { routes, location } , function ( error , redirectLocation ) {
99+ const history = createMemoryHistory ( )
100+ const location = history . createLocation ( '/company' )
101+ match ( { routes, history, location } , function ( error , redirectLocation ) {
99102 expect ( redirectLocation ) . toExist ( )
100103 expect ( redirectLocation . pathname ) . toEqual ( '/about' )
101104 expect ( redirectLocation . search ) . toEqual ( '' )
@@ -106,11 +109,12 @@ describe('server rendering', function () {
106109 } )
107110
108111 it ( 'sends null values when no routes match' , function ( done ) {
109- const location = createLocation ( '/no-match' )
110- match ( { routes, location } , function ( error , redirectLocation , state ) {
111- expect ( error ) . toBe ( null )
112- expect ( redirectLocation ) . toBe ( null )
113- expect ( state ) . toBe ( null )
112+ const history = createMemoryHistory ( )
113+ const location = history . createLocation ( '/no-match' )
114+ match ( { routes, history, location } , function ( error , redirectLocation , state ) {
115+ expect ( error ) . toNotExist ( )
116+ expect ( redirectLocation ) . toNotExist ( )
117+ expect ( state ) . toNotExist ( )
114118 done ( )
115119 } )
116120 } )
0 commit comments