Skip to content

Commit 0fabe35

Browse files
cherry-pick e401024 from 0.2.17
1 parent 0807247 commit 0fabe35

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/urlMatcherFactorySpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,27 @@ describe("urlMatcherFactory", function () {
597597
}).toThrow(new Error("Param 'foo' has two type configurations."));
598598
});
599599

600+
it("should match types named only in params", function () {
601+
var m = new UrlMatcher("/{foo}/{flag}", {
602+
params: {
603+
foo: { type: 'int'},
604+
flag: { type: 'bool'}
605+
}
606+
});
607+
expect(m.exec("/1138/1")).toEqual({foo: 1138, flag: true});
608+
expect(m.format({foo: 5, flag: true})).toBe("/5/1");
609+
});
610+
611+
it("should throw an error if a param type is declared twice", function () {
612+
expect(function() {
613+
new UrlMatcher("/{foo:int}", {
614+
params: {
615+
foo: {type: 'int'}
616+
}
617+
});
618+
}).toThrow(new Error("Param 'foo' has two type configurations."));
619+
});
620+
600621
it("should encode/decode dates", function () {
601622
var m = new UrlMatcher("/calendar/{date:date}"),
602623
result = m.exec("/calendar/2014-03-26");

0 commit comments

Comments
 (0)