@@ -106,6 +106,46 @@ describe("UrlRouter", function () {
106
106
expect ( called ) . toBeTruthy ( ) ;
107
107
expect ( location . path ( ) ) . toBe ( "/b4z" ) ;
108
108
} ) ) ;
109
+
110
+ describe ( "location updates" , function ( ) {
111
+ it ( 'can push location changes' , inject ( function ( $urlRouter , $location ) {
112
+ spyOn ( $location , "url" ) ;
113
+ spyOn ( $location , "replace" ) ;
114
+ $urlRouter . push ( new UrlMatcher ( "/hello/:name" ) , { name : "world" } ) ;
115
+
116
+ expect ( $location . url ) . toHaveBeenCalledWith ( "/hello/world" ) ;
117
+ expect ( $location . replace ) . not . toHaveBeenCalled ( ) ;
118
+ } ) ) ;
119
+
120
+ it ( 'can push a replacement location' , inject ( function ( $urlRouter , $location ) {
121
+ spyOn ( $location , "url" ) ;
122
+ spyOn ( $location , "replace" ) ;
123
+ $urlRouter . push ( new UrlMatcher ( "/hello/:name" ) , { name : "world" } , { replace : true } ) ;
124
+
125
+ expect ( $location . url ) . toHaveBeenCalledWith ( "/hello/world" ) ;
126
+ expect ( $location . replace ) . toHaveBeenCalled ( ) ;
127
+ } ) ) ;
128
+
129
+ it ( 'can push location changes with no parameters' , inject ( function ( $urlRouter , $location ) {
130
+ spyOn ( $location , "url" ) ;
131
+ $urlRouter . push ( new UrlMatcher ( "/hello/:name" ) ) ;
132
+
133
+ expect ( $location . url ) . toHaveBeenCalledWith ( "/hello/" ) ;
134
+ } ) ) ;
135
+
136
+ it ( 'can read and sync a copy of location URL' , inject ( function ( $urlRouter , $location ) {
137
+ $location . url ( '/old' ) ;
138
+
139
+ spyOn ( $location , 'url' ) . andCallThrough ( ) ;
140
+ $urlRouter . update ( true ) ;
141
+ expect ( $location . url ) . toHaveBeenCalled ( ) ;
142
+
143
+ $location . url ( '/new' ) ;
144
+ $urlRouter . update ( ) ;
145
+
146
+ expect ( $location . url ( ) ) . toBe ( '/old' ) ;
147
+ } ) ) ;
148
+ } ) ;
109
149
} ) ;
110
150
111
151
} ) ;
0 commit comments