1616
1717import { GridAlgorithm } from "./grid" ;
1818import { initialize , MapCanvasProjection } from "@googlemaps/jest-mocks" ;
19- import { Marker } from "../marker-utils" ;
2019
2120initialize ( ) ;
2221const markers = [
@@ -35,7 +34,7 @@ describe.each(markers)(
3534
3635 test ( "calculate should return changed: true for first call when zoom > max zoom" , ( ) => {
3736 const mapCanvasProjection = new MapCanvasProjection ( ) ;
38- const markers : Marker [ ] = [ marker ] ;
37+ const markers = [ marker ] ;
3938
4039 const grid = new GridAlgorithm ( { maxZoom : 16 } ) ;
4140 grid [ "noop" ] = jest . fn ( ) ;
@@ -60,10 +59,10 @@ describe.each(markers)(
6059 expect ( changed ) . toBe ( true ) ;
6160 } ) ;
6261
63- test ( "calculate should return changed: false for next calls above max zoom " , ( ) => {
62+ test ( "calculate should return changed: false when zoom doesn't change " , ( ) => {
6463 const mapCanvasProjection =
6564 jest . fn ( ) as unknown as google . maps . MapCanvasProjection ;
66- const markers : Marker [ ] = [ marker ] ;
65+ const markers = [ marker ] ;
6766
6867 const grid = new GridAlgorithm ( { maxZoom : 16 } ) ;
6968 grid [ "noop" ] = jest . fn ( ) ;
@@ -87,10 +86,10 @@ describe.each(markers)(
8786 expect ( result . changed ) . toBe ( false ) ;
8887 } ) ;
8988
90- test ( "calculate should return changed: false for next calls above max zoom, even if zoom changed" , ( ) => {
89+ test ( "calculate should return changed: false for next calls at or above max zoom, even if zoom changed" , ( ) => {
9190 const mapCanvasProjection =
9291 jest . fn ( ) as unknown as google . maps . MapCanvasProjection ;
93- const markers : Marker [ ] = [ marker ] ;
92+ const markers = [ marker ] ;
9493
9594 const grid = new GridAlgorithm ( { maxZoom : 16 } ) ;
9695 grid [ "noop" ] = jest . fn ( ) ;
@@ -114,6 +113,16 @@ describe.each(markers)(
114113 } ) ;
115114
116115 expect ( result . changed ) . toBe ( false ) ;
116+
117+ map . getZoom = jest . fn ( ) . mockReturnValue ( 16 ) ;
118+
119+ result = grid . calculate ( {
120+ markers,
121+ map,
122+ mapCanvasProjection,
123+ } ) ;
124+
125+ expect ( result . changed ) . toBe ( false ) ;
117126 } ) ;
118127 }
119128) ;
0 commit comments