@@ -7,27 +7,16 @@ declare var inject;
7
7
8
8
var module = angular [ 'mock' ] . module ;
9
9
10
- var router : UIRouter ;
11
- var $umf : UrlMatcherFactory ;
12
- var $url : UrlService ;
13
-
14
- beforeEach ( function ( ) {
15
- var app = angular . module ( 'ui.router.router.test' , [ ] ) ;
16
- app . config ( function ( $uiRouterProvider ) {
17
- $umf = $uiRouterProvider . urlMatcherFactory ;
18
- $url = $uiRouterProvider . urlService ;
19
- } ) ;
20
- } ) ;
21
-
22
10
describe ( "UrlMatcher" , function ( ) {
23
- beforeEach ( function ( ) {
24
- module ( 'ui.router.router' , 'ui.router.router.test' ) ;
11
+ var router : UIRouter ;
12
+ var $umf : UrlMatcherFactory ;
13
+ var $url : UrlService ;
25
14
26
- inject ( function ( $injector ) {
27
- router = $injector . get ( '$ uiRouter' ) ;
28
- $injector . invoke ( $ umf. $get , $umf ) ;
29
- } ) ;
30
- } ) ;
15
+ beforeEach ( inject ( function ( $uiRouter , $urlMatcherFactory , $urlService ) {
16
+ router = $uiRouter ;
17
+ $ umf = $urlMatcherFactory ;
18
+ $url = $urlService ;
19
+ } ) ) ;
31
20
32
21
describe ( "provider" , function ( ) {
33
22
@@ -563,7 +552,7 @@ describe("UrlMatcher", function () {
563
552
564
553
describe ( "urlMatcherFactoryProvider" , function ( ) {
565
554
describe ( ".type()" , function ( ) {
566
- var m ;
555
+ var $umf ;
567
556
beforeEach ( module ( 'ui.router.util' , function ( $urlMatcherFactoryProvider ) {
568
557
$umf = $urlMatcherFactoryProvider ;
569
558
$urlMatcherFactoryProvider . type ( "myType" , { } , function ( ) {
@@ -572,10 +561,10 @@ describe("urlMatcherFactoryProvider", function () {
572
561
is : angular . isObject
573
562
} ;
574
563
} ) ;
575
- m = $umf . compile ( "/test?{foo:myType}" ) ;
576
564
} ) ) ;
577
565
578
566
it ( "should handle arrays properly with config-time custom type definitions" , inject ( function ( $stateParams ) {
567
+ var m = $umf . compile ( "/test?{foo:myType}" ) ;
579
568
expect ( m . exec ( "/test" , { foo : '1' } ) ) . toEqual ( { foo : { status : 'decoded' } } ) ;
580
569
expect ( m . exec ( "/test" , { foo : [ '1' , '2' ] } ) ) . toEqual ( { foo : [ { status : 'decoded' } , { status : 'decoded' } ] } ) ;
581
570
} ) ) ;
@@ -588,15 +577,12 @@ describe("urlMatcherFactoryProvider", function () {
588
577
} ) ;
589
578
590
579
describe ( "urlMatcherFactory" , function ( ) {
580
+ var $umf : UrlMatcherFactory ;
581
+ var $url : UrlService ;
591
582
592
- var $umf ;
593
-
594
- beforeEach ( module ( 'ui.router.util' , function ( $urlMatcherFactoryProvider ) {
595
- $umf = $urlMatcherFactoryProvider ;
596
- } ) ) ;
597
-
598
- beforeEach ( inject ( function ( $urlMatcherFactory ) {
583
+ beforeEach ( inject ( function ( $urlMatcherFactory , $urlService ) {
599
584
$umf = $urlMatcherFactory ;
585
+ $url = $urlService ;
600
586
} ) ) ;
601
587
602
588
it ( "compiles patterns" , function ( ) {
@@ -630,35 +616,35 @@ describe("urlMatcherFactory", function () {
630
616
631
617
describe ( "typed parameters" , function ( ) {
632
618
it ( "should accept object definitions" , function ( ) {
633
- var type = { encode : function ( ) { } , decode : function ( ) { } } ;
619
+ var type = { encode : function ( ) { } , decode : function ( ) { } } as any ;
634
620
$umf . type ( "myType1" , type ) ;
635
621
expect ( $umf . type ( "myType1" ) . encode ) . toBe ( type . encode ) ;
636
622
} ) ;
637
623
638
624
it ( "should reject duplicate definitions" , function ( ) {
639
- $umf . type ( "myType2" , { encode : function ( ) { } , decode : function ( ) { } } ) ;
640
- expect ( function ( ) { $umf . type ( "myType2" , { } ) ; } ) . toThrowError ( "A type named 'myType2' has already been defined." ) ;
625
+ $umf . type ( "myType2" , { encode : function ( ) { } , decode : function ( ) { } } as any ) ;
626
+ expect ( function ( ) { $umf . type ( "myType2" , { } as any ) ; } ) . toThrowError ( "A type named 'myType2' has already been defined." ) ;
641
627
} ) ;
642
628
643
629
it ( "should accept injected function definitions" , inject ( function ( $stateParams ) {
644
- $umf . type ( "myType3" , { } , function ( $stateParams ) {
630
+ $umf . type ( "myType3" , { } as any , function ( $stateParams ) {
645
631
return {
646
632
decode : function ( ) {
647
633
return $stateParams ;
648
634
}
649
635
} ;
650
- } ) ;
636
+ } as any ) ;
651
637
expect ( $umf . type ( "myType3" ) . decode ( ) ) . toBe ( $stateParams ) ;
652
638
} ) ) ;
653
639
654
640
it ( "should accept annotated function definitions" , inject ( function ( $stateParams ) {
655
- $umf . type ( "myAnnotatedType" , { } , [ '$stateParams' , function ( s ) {
641
+ $umf . type ( "myAnnotatedType" , { } as any , [ '$stateParams' , function ( s ) {
656
642
return {
657
643
decode : function ( ) {
658
644
return s ;
659
645
}
660
646
} ;
661
- } ] ) ;
647
+ } ] as any ) ;
662
648
expect ( $umf . type ( "myAnnotatedType" ) . decode ( ) ) . toBe ( $stateParams ) ;
663
649
} ) ) ;
664
650
@@ -997,28 +983,4 @@ describe("urlMatcherFactory", function () {
997
983
expect ( m . exec ( '/users/bob//' ) ) . toBeNull ( ) ;
998
984
} ) ;
999
985
} ) ;
1000
-
1001
- xdescribe ( "parameter isolation" , function ( ) {
1002
- it ( "should allow parameters of the same name in different segments" , function ( ) {
1003
- var m = $umf . compile ( '/users/:id' ) . append ( $umf . compile ( '/photos/:id' ) ) ;
1004
- expect ( m . exec ( '/users/11/photos/38' , { } , { isolate : true } ) ) . toEqual ( [ { id : '11' } , { id : '38' } ] ) ;
1005
- } ) ;
1006
-
1007
- it ( "should prioritize the last child when non-isolated" , function ( ) {
1008
- var m = $umf . compile ( '/users/:id' ) . append ( $umf . compile ( '/photos/:id' ) ) ;
1009
- expect ( m . exec ( '/users/11/photos/38' ) ) . toEqual ( { id : '38' } ) ;
1010
- } ) ;
1011
-
1012
- it ( "should copy search parameter values to all matching segments" , function ( ) {
1013
- var m = $umf . compile ( '/users/:id?from' ) . append ( $umf . compile ( '/photos/:id?from' ) ) ;
1014
- var result = m . exec ( '/users/11/photos/38' , { from : "bob" } , { isolate : true } ) ;
1015
- expect ( result ) . toEqual ( [ { from : "bob" , id : "11" } , { from : "bob" , id : "38" } ] ) ;
1016
- } ) ;
1017
-
1018
- it ( "should pair empty objects with static segments" , function ( ) {
1019
- var m = $umf . compile ( '/users/:id' ) . append ( $umf . compile ( '/foo' ) ) . append ( $umf . compile ( '/photos/:id' ) ) ;
1020
- var result = m . exec ( '/users/11/foo/photos/38' , { } , { isolate : true } ) ;
1021
- expect ( result ) . toEqual ( [ { id : '11' } , { } , { id : '38' } ] ) ;
1022
- } ) ;
1023
- } ) ;
1024
986
} ) ;
0 commit comments