test(router): add missing tests for the url parser

This commit is contained in:
Brian Ford 2015-10-13 10:05:10 -07:00
parent 8bc40d3f4d
commit c0b7bae9d3

View File

@ -29,6 +29,11 @@ export function main() {
expect(url.toString()).toEqual('hello/there'); expect(url.toString()).toEqual('hello/there');
}); });
it('should parse an empty URL', () => {
var url = urlParser.parse('');
expect(url.toString()).toEqual('');
});
it('should work with a single aux route', () => { it('should work with a single aux route', () => {
var url = urlParser.parse('hello/there(a)'); var url = urlParser.parse('hello/there(a)');
expect(url.toString()).toEqual('hello/there(a)'); expect(url.toString()).toEqual('hello/there(a)');
@ -79,6 +84,11 @@ export function main() {
expect(url.toString()).toEqual('hello/there;hi'); expect(url.toString()).toEqual('hello/there;hi');
}); });
it('should parse a URL with just a query param', () => {
var url = urlParser.parse('?name=bob');
expect(url.toString()).toEqual('?name=bob');
});
it('should parse a key-value query param', () => { it('should parse a key-value query param', () => {
var url = urlParser.parse('hello/friend?name=bob'); var url = urlParser.parse('hello/friend?name=bob');
expect(url.toString()).toEqual('hello/friend?name=bob'); expect(url.toString()).toEqual('hello/friend?name=bob');
@ -90,7 +100,7 @@ export function main() {
expect(url.toString()).toEqual('hello/there?greeting=hi&whats=up'); expect(url.toString()).toEqual('hello/there?greeting=hi&whats=up');
}); });
it('should parse a key-only matrix param', () => { it('should parse a key-only query param', () => {
var url = urlParser.parse('hello/there?hi'); var url = urlParser.parse('hello/there?hi');
expect(url.toString()).toEqual('hello/there?hi'); expect(url.toString()).toEqual('hello/there?hi');
}); });