git.fiddlerwoaroof.com
Browse code

Add a test for a edge case found in refactoring.

Ed Langley authored on 16/06/2017 00:32:43
Showing 1 changed files
... ...
@@ -204,6 +204,23 @@ it("router should match less-wildcarded routes in preference to more wildcarded
204 204
 
205 205
 });
206 206
 
207
+it("router should propagate matches through non-matching cases", () => {
208
+  //given
209
+  const routesConfig = [
210
+    ["/somewhere/specific/:view", "ACTION_NAME", {id: 1}],
211
+    ["/somewhere/:id/:view", "ACTION_NAME", {}],
212
+    ["/not/a/match", "ACTION_NAME", {}]
213
+  ];
214
+  const {actionsDispatched, fireUrlChange} = setupTest(routesConfig);
215
+
216
+  // when
217
+  fireUrlChange('/somewhere/specific/etc');
218
+
219
+  // then
220
+  expect(actionsDispatched()).toEqual([{type:'ACTION_NAME', id: 1, view: "etc"}]);
221
+
222
+});
223
+
207 224
 it("router should give precedence to exact match first in equally-specific routes (/a/:b vs /:a/b)", () => {
208 225
   // given
209 226
   const routesConfig = [