@@ -98,6 +98,83 @@ describe("A <Route>", () => {
9898 } ) ;
9999 } ) ;
100100
101+ describe ( "with an array of paths" , ( ) => {
102+ it ( "matches the first provided path" , ( ) => {
103+ const node = document . createElement ( "div" ) ;
104+ ReactDOM . render (
105+ < MemoryRouter initialEntries = { [ "/hello" ] } >
106+ < Route
107+ path = { [ "/hello" , "/world" ] }
108+ render = { ( ) => < div > Hello World</ div > }
109+ />
110+ </ MemoryRouter > ,
111+ node
112+ ) ;
113+
114+ expect ( node . innerHTML ) . toContain ( "Hello World" ) ;
115+ } ) ;
116+
117+ it ( "matches other provided paths" , ( ) => {
118+ const node = document . createElement ( "div" ) ;
119+ ReactDOM . render (
120+ < MemoryRouter initialEntries = { [ "/other" , "/world" ] } initialIndex = { 1 } >
121+ < Route
122+ path = { [ "/hello" , "/world" ] }
123+ render = { ( ) => < div > Hello World</ div > }
124+ />
125+ </ MemoryRouter > ,
126+ node
127+ ) ;
128+
129+ expect ( node . innerHTML ) . toContain ( "Hello World" ) ;
130+ } ) ;
131+
132+ it ( "provides the matched path as a string" , ( ) => {
133+ const node = document . createElement ( "div" ) ;
134+ ReactDOM . render (
135+ < MemoryRouter initialEntries = { [ "/other" , "/world" ] } initialIndex = { 1 } >
136+ < Route
137+ path = { [ "/hello" , "/world" ] }
138+ render = { ( { match } ) => < div > { match . path } </ div > }
139+ />
140+ </ MemoryRouter > ,
141+ node
142+ ) ;
143+
144+ expect ( node . innerHTML ) . toContain ( "/world" ) ;
145+ } ) ;
146+
147+ it ( "doesn't remount when moving from one matching path to another" , ( ) => {
148+ const node = document . createElement ( "div" ) ;
149+ const history = createHistory ( ) ;
150+ const mount = jest . fn ( ) ;
151+ class MatchedRoute extends React . Component {
152+ componentWillMount ( ) {
153+ mount ( ) ;
154+ }
155+
156+ render ( ) {
157+ return < div > Hello World</ div > ;
158+ }
159+ }
160+ history . push ( "/hello" ) ;
161+ ReactDOM . render (
162+ < Router history = { history } >
163+ < Route path = { [ "/hello" , "/world" ] } component = { MatchedRoute } />
164+ </ Router > ,
165+ node
166+ ) ;
167+
168+ expect ( mount ) . toHaveBeenCalledTimes ( 1 ) ;
169+ expect ( node . innerHTML ) . toContain ( "Hello World" ) ;
170+
171+ history . push ( "/world/somewhere/else" ) ;
172+
173+ expect ( mount ) . toHaveBeenCalledTimes ( 1 ) ;
174+ expect ( node . innerHTML ) . toContain ( "Hello World" ) ;
175+ } ) ;
176+ } ) ;
177+
101178 describe ( "with a unicode path" , ( ) => {
102179 it ( "is able to match" , ( ) => {
103180 ReactDOM . render (
0 commit comments