1+ import {
2+ ComponentFixture ,
3+ AsyncTestCompleter ,
4+ TestComponentBuilder ,
5+ beforeEach ,
6+ ddescribe ,
7+ xdescribe ,
8+ describe ,
9+ el ,
10+ expect ,
11+ iit ,
12+ inject ,
13+ beforeEachProviders ,
14+ it ,
15+ xit
16+ } from 'angular2/testing_internal' ;
17+
18+ import { DefaultRouterUrlParser } from 'angular2/src/alt_router/router_url_parser' ;
19+ import { UrlSegment } from 'angular2/src/alt_router/segments' ;
20+
21+ export function main ( ) {
22+ describe ( 'url parsing' , ( ) => {
23+ let parser = new DefaultRouterUrlParser ( ) ;
24+
25+ it ( 'should throw on an empty urls' , ( ) => { expect ( ( ) => parser . parse ( "" ) ) . toThrow ( ) ; } ) ;
26+
27+ it ( 'should parse the root url' , ( ) => {
28+ let tree = parser . parse ( "/" ) ;
29+ expect ( tree . root ) . toEqual ( new UrlSegment ( "/" , { } , "" ) ) ;
30+ } ) ;
31+
32+ it ( 'should parse non-empty urls' , ( ) => {
33+ let tree = parser . parse ( "one/two/three" ) ;
34+ expect ( tree . root ) . toEqual ( new UrlSegment ( "one" , { } , "" ) ) ;
35+ expect ( tree . firstChild ( tree . root ) ) . toEqual ( new UrlSegment ( "two" , { } , "" ) ) ;
36+ expect ( tree . firstChild ( tree . firstChild ( tree . root ) ) ) . toEqual ( new UrlSegment ( "three" , { } , "" ) ) ;
37+ } ) ;
38+
39+ it ( 'should parse non-empty absolute urls' , ( ) => {
40+ let tree = parser . parse ( "/one/two" ) ;
41+ expect ( tree . root ) . toEqual ( new UrlSegment ( "/one" , { } , "" ) ) ;
42+ expect ( tree . firstChild ( tree . root ) ) . toEqual ( new UrlSegment ( "two" , { } , "" ) ) ;
43+ } ) ;
44+ } ) ;
45+ }
0 commit comments