Skip to content

Commit 7ef8f3c

Browse files
committed
test(UrlMatcher): optional params between statics
Ensure that optional parameters that exist between static segments can be matched (or not matched) correctly.
1 parent 00966ec commit 7ef8f3c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/urlMatcherFactorySpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ describe("urlMatcherFactory", function () {
310310
expect(m.format({ id: 1138, state: "NY" })).toBe("/users/1138/NY");
311311
});
312312

313+
it("should match in between static segments", function() {
314+
var m = new UrlMatcher('/users/{user:int}/photos', {
315+
params: { user: 5 }
316+
});
317+
expect(m.exec('/users/photos').user).toBe(5);
318+
expect(m.exec('/users/6/photos').user).toBe(6);
319+
expect(m.format()).toBe("/users/photos");
320+
expect(m.format({ user: 1138 })).toBe("/users/1138/photos");
321+
});
322+
313323
describe("default values", function() {
314324
it("should populate if not supplied in URL", function() {
315325
var m = new UrlMatcher('/users/{id:int}/{test}', {

0 commit comments

Comments
 (0)