Skip to content

Commit

Permalink
test(UrlMatcher): optional params between statics
Browse files Browse the repository at this point in the history
Ensure that optional parameters that exist between static segments can be matched (or not matched) correctly.
  • Loading branch information
nateabele committed Apr 19, 2014
1 parent 00966ec commit 7ef8f3c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/urlMatcherFactorySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,16 @@ describe("urlMatcherFactory", function () {
expect(m.format({ id: 1138, state: "NY" })).toBe("/users/1138/NY");
});

it("should match in between static segments", function() {
var m = new UrlMatcher('/users/{user:int}/photos', {
params: { user: 5 }
});
expect(m.exec('/users/photos').user).toBe(5);
expect(m.exec('/users/6/photos').user).toBe(6);
expect(m.format()).toBe("/users/photos");
expect(m.format({ user: 1138 })).toBe("/users/1138/photos");
});

describe("default values", function() {
it("should populate if not supplied in URL", function() {
var m = new UrlMatcher('/users/{id:int}/{test}', {
Expand Down

0 comments on commit 7ef8f3c

Please sign in to comment.