@@ -160,25 +160,36 @@ describe("LocationLite", () => {
160160 text : 'preserve' ,
161161 expectedQs : '?plus=another&extra=thing' ,
162162 } ,
163- ] )
164- ( "Should $text the query string when instructed by the value $preserveQuery in the preserveQuery option." , ( { qs, preserveQuery, expectedQs } ) => {
165- // Arrange.
166- location . url . search = window . location . search = qs ;
167- const newPath = '/new/path' ;
163+ ] ) ( "Should $text the query string when instructed by the value $preserveQuery in the preserveQuery option." , ( { qs, preserveQuery, expectedQs } ) => {
164+ // Arrange.
165+ location . url . search = window . location . search = qs ;
166+ const newPath = '/new/path' ;
168167
169- // Act.
170- location . goTo ( newPath , { preserveQuery } ) ;
168+ // Act.
169+ location . goTo ( newPath , { preserveQuery } ) ;
171170
172- // Assert.
173- expect ( window . location . pathname ) . to . equal ( newPath ) ;
174- expect ( window . location . search ) . to . equal ( `${ expectedQs } ` ) ;
175- } ) ;
171+ // Assert.
172+ expect ( window . location . pathname ) . to . equal ( newPath ) ;
173+ expect ( window . location . search ) . to . equal ( `${ expectedQs } ` ) ;
174+ } ) ;
175+ test ( "Should ignore the preserveQuery option when doing shallow routing." , ( ) => {
176+ // Arrange.
177+ const currentPath = "/current/path" ;
178+ window . location . href = `${ currentPath } ?some=value&plus=another` ;
179+ location . url . href = window . location . href ;
180+ console . debug ( 'Path: ' , window . location . pathname ) ;
181+
182+ // Act.
183+ location . goTo ( '' , { preserveQuery : true } ) ;
184+ // Assert.
185+ expect ( window . location . pathname ) . to . equal ( currentPath ) ;
186+ } ) ;
176187 } ) ;
177188 describe ( 'navigate' , ( ) => {
178189 afterEach ( ( ) => {
179190 resetRoutingOptions ( ) ;
180191 } ) ;
181-
192+
182193 test . each < {
183194 qs : string ;
184195 preserveQuery : PreserveQuery ;
@@ -229,17 +240,17 @@ describe("LocationLite", () => {
229240 {
230241 hash : ALL_HASHES . path ,
231242 desc : 'path' ,
232- options : { disallowPathRouting : true }
243+ options : { disallowPathRouting : true }
233244 } ,
234245 {
235246 hash : ALL_HASHES . single ,
236247 desc : 'hash' ,
237- options : { disallowHashRouting : true }
248+ options : { disallowHashRouting : true }
238249 } ,
239250 {
240251 hash : ALL_HASHES . multi ,
241252 desc : 'multi hash' ,
242- options : { disallowMultiHashRouting : true }
253+ options : { disallowMultiHashRouting : true }
243254 } ,
244255 ] ) ( "Should throw an error when the hash option is $hash and $desc routing is disallowed." , ( { hash, options } ) => {
245256 // Arrange.
0 commit comments