@@ -7,27 +7,16 @@ declare var inject;
77
88var module = angular [ 'mock' ] . module ;
99
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-
2210describe ( "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 ;
2514
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+ } ) ) ;
3120
3221 describe ( "provider" , function ( ) {
3322
@@ -563,7 +552,7 @@ describe("UrlMatcher", function () {
563552
564553describe ( "urlMatcherFactoryProvider" , function ( ) {
565554 describe ( ".type()" , function ( ) {
566- var m ;
555+ var $umf ;
567556 beforeEach ( module ( 'ui.router.util' , function ( $urlMatcherFactoryProvider ) {
568557 $umf = $urlMatcherFactoryProvider ;
569558 $urlMatcherFactoryProvider . type ( "myType" , { } , function ( ) {
@@ -572,10 +561,10 @@ describe("urlMatcherFactoryProvider", function () {
572561 is : angular . isObject
573562 } ;
574563 } ) ;
575- m = $umf . compile ( "/test?{foo:myType}" ) ;
576564 } ) ) ;
577565
578566 it ( "should handle arrays properly with config-time custom type definitions" , inject ( function ( $stateParams ) {
567+ var m = $umf . compile ( "/test?{foo:myType}" ) ;
579568 expect ( m . exec ( "/test" , { foo : '1' } ) ) . toEqual ( { foo : { status : 'decoded' } } ) ;
580569 expect ( m . exec ( "/test" , { foo : [ '1' , '2' ] } ) ) . toEqual ( { foo : [ { status : 'decoded' } , { status : 'decoded' } ] } ) ;
581570 } ) ) ;
@@ -588,15 +577,12 @@ describe("urlMatcherFactoryProvider", function () {
588577} ) ;
589578
590579describe ( "urlMatcherFactory" , function ( ) {
580+ var $umf : UrlMatcherFactory ;
581+ var $url : UrlService ;
591582
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 ) {
599584 $umf = $urlMatcherFactory ;
585+ $url = $urlService ;
600586 } ) ) ;
601587
602588 it ( "compiles patterns" , function ( ) {
@@ -630,35 +616,35 @@ describe("urlMatcherFactory", function () {
630616
631617 describe ( "typed parameters" , function ( ) {
632618 it ( "should accept object definitions" , function ( ) {
633- var type = { encode : function ( ) { } , decode : function ( ) { } } ;
619+ var type = { encode : function ( ) { } , decode : function ( ) { } } as any ;
634620 $umf . type ( "myType1" , type ) ;
635621 expect ( $umf . type ( "myType1" ) . encode ) . toBe ( type . encode ) ;
636622 } ) ;
637623
638624 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." ) ;
641627 } ) ;
642628
643629 it ( "should accept injected function definitions" , inject ( function ( $stateParams ) {
644- $umf . type ( "myType3" , { } , function ( $stateParams ) {
630+ $umf . type ( "myType3" , { } as any , function ( $stateParams ) {
645631 return {
646632 decode : function ( ) {
647633 return $stateParams ;
648634 }
649635 } ;
650- } ) ;
636+ } as any ) ;
651637 expect ( $umf . type ( "myType3" ) . decode ( ) ) . toBe ( $stateParams ) ;
652638 } ) ) ;
653639
654640 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 ) {
656642 return {
657643 decode : function ( ) {
658644 return s ;
659645 }
660646 } ;
661- } ] ) ;
647+ } ] as any ) ;
662648 expect ( $umf . type ( "myAnnotatedType" ) . decode ( ) ) . toBe ( $stateParams ) ;
663649 } ) ) ;
664650
@@ -997,28 +983,4 @@ describe("urlMatcherFactory", function () {
997983 expect ( m . exec ( '/users/bob//' ) ) . toBeNull ( ) ;
998984 } ) ;
999985 } ) ;
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- } ) ;
1024986} ) ;
0 commit comments