2
2
/*eslint react/prop-types: 0*/
3
3
import expect from 'expect'
4
4
import React from 'react'
5
- import createLocation from 'history/lib/createLocation '
5
+ import createMemoryHistory from 'history/lib/createMemoryHistory '
6
6
import RoutingContext from '../RoutingContext'
7
7
import match from '../match'
8
8
import Link from '../Link'
@@ -71,8 +71,9 @@ describe('server rendering', function () {
71
71
} )
72
72
73
73
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 ) {
76
77
const string = React . renderToString (
77
78
< RoutingContext { ...renderProps } />
78
79
)
@@ -82,8 +83,9 @@ describe('server rendering', function () {
82
83
} )
83
84
84
85
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 ) {
87
89
const string = React . renderToString (
88
90
< RoutingContext { ...renderProps } />
89
91
)
@@ -94,8 +96,9 @@ describe('server rendering', function () {
94
96
} )
95
97
96
98
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 ) {
99
102
expect ( redirectLocation ) . toExist ( )
100
103
expect ( redirectLocation . pathname ) . toEqual ( '/about' )
101
104
expect ( redirectLocation . search ) . toEqual ( '' )
@@ -106,11 +109,12 @@ describe('server rendering', function () {
106
109
} )
107
110
108
111
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 ( )
114
118
done ( )
115
119
} )
116
120
} )
0 commit comments