@@ -327,6 +327,71 @@ describe('hash', () => {
327
327
expect ( window . location . hash ) . toBe ( '#baz&foo=bar' ) ;
328
328
} ) ;
329
329
330
+ test ( 'initialize http://localhost/#' , ( ) => {
331
+ window . location . href = 'http://localhost/#' ;
332
+ createHash ( ) . addTo ( map ) ;
333
+ map . setZoom ( 3 ) ;
334
+ expect ( window . location . hash ) . toBe ( '#3/0/0' ) ;
335
+ expect ( window . location . href ) . toBe ( 'http://localhost/#3/0/0' ) ;
336
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
337
+ expect ( window . location . hash ) . toBe ( '#3/1/2' ) ;
338
+ expect ( window . location . href ) . toBe ( 'http://localhost/#3/1/2' ) ;
339
+ } ) ;
340
+
341
+ test ( 'initialize http://localhost/##' , ( ) => {
342
+ window . location . href = 'http://localhost/##' ;
343
+ createHash ( ) . addTo ( map ) ;
344
+ map . setZoom ( 3 ) ;
345
+ expect ( window . location . hash ) . toBe ( '#3/0/0' ) ;
346
+ expect ( window . location . href ) . toBe ( 'http://localhost/#3/0/0' ) ;
347
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
348
+ expect ( window . location . hash ) . toBe ( '#3/1/2' ) ;
349
+ expect ( window . location . href ) . toBe ( 'http://localhost/#3/1/2' ) ;
350
+ } ) ;
351
+
352
+ test ( 'initialize http://localhost#' , ( ) => {
353
+ window . location . href = 'http://localhost#' ;
354
+ createHash ( ) . addTo ( map ) ;
355
+ map . setZoom ( 4 ) ;
356
+ expect ( window . location . hash ) . toBe ( '#4/0/0' ) ;
357
+ expect ( window . location . href ) . toBe ( 'http://localhost/#4/0/0' ) ;
358
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
359
+ expect ( window . location . hash ) . toBe ( '#4/1/2' ) ;
360
+ expect ( window . location . href ) . toBe ( 'http://localhost/#4/1/2' ) ;
361
+ } ) ;
362
+
363
+ test ( 'initialize http://localhost/' , ( ) => {
364
+ window . location . href = 'http://localhost/' ;
365
+ createHash ( ) . addTo ( map ) ;
366
+ map . setZoom ( 5 ) ;
367
+ expect ( window . location . hash ) . toBe ( '#5/0/0' ) ;
368
+ expect ( window . location . href ) . toBe ( 'http://localhost/#5/0/0' ) ;
369
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
370
+ expect ( window . location . hash ) . toBe ( '#5/1/2' ) ;
371
+ expect ( window . location . href ) . toBe ( 'http://localhost/#5/1/2' ) ;
372
+ } ) ;
373
+
374
+ test ( 'initialize default value for window.location.href' , ( ) => {
375
+ createHash ( ) . addTo ( map ) ;
376
+ map . setZoom ( 5 ) ;
377
+ expect ( window . location . hash ) . toBe ( '#5/0/0' ) ;
378
+ expect ( window . location . href ) . toBe ( 'http://localhost/#5/0/0' ) ;
379
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
380
+ expect ( window . location . hash ) . toBe ( '#5/1/2' ) ;
381
+ expect ( window . location . href ) . toBe ( 'http://localhost/#5/1/2' ) ;
382
+ } ) ;
383
+
384
+ test ( 'initialize http://localhost' , ( ) => {
385
+ window . location . href = 'http://localhost' ;
386
+ createHash ( ) . addTo ( map ) ;
387
+ map . setZoom ( 4 ) ;
388
+ expect ( window . location . hash ) . toBe ( '#4/0/0' ) ;
389
+ expect ( window . location . href ) . toBe ( 'http://localhost/#4/0/0' ) ;
390
+ map . setCenter ( [ 2.0 , 1.0 ] ) ;
391
+ expect ( window . location . hash ) . toBe ( '#4/1/2' ) ;
392
+ expect ( window . location . href ) . toBe ( 'http://localhost/#4/1/2' ) ;
393
+ } ) ;
394
+
330
395
test ( 'map#remove' , ( ) => {
331
396
const container = window . document . createElement ( 'div' ) ;
332
397
Object . defineProperty ( container , 'clientWidth' , { value : 512 } ) ;
0 commit comments