@@ -11,12 +11,19 @@ import { createSandboxFromDefaultPreferences } from 'compass-preferences-model';
11
11
import { createNoopLogger } from '@mongodb-js/compass-logging/provider' ;
12
12
import type { FieldStoreService } from '@mongodb-js/compass-field-store' ;
13
13
import { createNoopTrack } from '@mongodb-js/compass-telemetry/provider' ;
14
- import { startAnalysis , stopAnalysis } from './schema-analysis-reducer' ;
14
+ import {
15
+ geoLayerAdded ,
16
+ geoLayersDeleted ,
17
+ geoLayersEdited ,
18
+ startAnalysis ,
19
+ stopAnalysis ,
20
+ } from './schema-analysis-reducer' ;
15
21
import Sinon from 'sinon' ;
16
22
import {
17
23
changeExportSchemaFormat ,
18
24
openExportSchema ,
19
25
} from './schema-export-reducer' ;
26
+ import { Circle , LayerGroup , Polygon } from 'leaflet' ;
20
27
21
28
const dummyLogger = createNoopLogger ( 'TEST' ) ;
22
29
const dummyTrack = createNoopTrack ( ) ;
@@ -154,6 +161,62 @@ describe('Schema Store', function () {
154
161
expect ( store . getState ( ) . schemaAnalysis . analysisState ) . to . equal ( 'initial' ) ;
155
162
} ) ;
156
163
164
+ describe ( 'geoLayers' , function ( ) {
165
+ it ( 'geoLayerAdded, geoLayersEdited, geoLayersDeleted: calls the onChange callback' , function ( ) {
166
+ const layer = new Circle ( [ 1 , 2 ] , {
167
+ radius : 1000 ,
168
+ } ) ;
169
+ const onChangeSpy = sandbox . spy ( ) ;
170
+ store . dispatch ( geoLayerAdded ( 'coordinates' , layer , onChangeSpy ) ) ;
171
+ expect ( onChangeSpy ) . to . have . been . calledOnceWith ( {
172
+ coordinates : {
173
+ $geoWithin : {
174
+ $centerSphere : Sinon . match . array ,
175
+ } ,
176
+ } ,
177
+ } ) ;
178
+ } ) ;
179
+
180
+ it ( 'geoLayersEdited: calls the onChange callback' , function ( ) {
181
+ const layersGroup = new LayerGroup ( ) ;
182
+ layersGroup . addLayer (
183
+ new Polygon ( [
184
+ [ 1 , 2 ] ,
185
+ [ 3 , 4 ] ,
186
+ [ 5 , 6 ] ,
187
+ ] )
188
+ ) ;
189
+ const onChangeSpy = sandbox . spy ( ) ;
190
+ store . dispatch (
191
+ geoLayersEdited ( 'coordinates' , layersGroup , onChangeSpy )
192
+ ) ;
193
+ expect ( onChangeSpy ) . to . have . been . calledOnceWith ( {
194
+ coordinates : {
195
+ $geoWithin : {
196
+ $geometry : {
197
+ type : 'Polygon' ,
198
+ coordinates : Sinon . match . array ,
199
+ } ,
200
+ } ,
201
+ } ,
202
+ } ) ;
203
+ } ) ;
204
+
205
+ it ( 'geoLayersDeleted: calls the onChange callback' , function ( ) {
206
+ const layersGroup = new LayerGroup ( ) ;
207
+ layersGroup . addLayer (
208
+ new Polygon ( [
209
+ [ 1 , 2 ] ,
210
+ [ 3 , 4 ] ,
211
+ [ 5 , 6 ] ,
212
+ ] )
213
+ ) ;
214
+ const onChangeSpy = sandbox . spy ( ) ;
215
+ store . dispatch ( geoLayersDeleted ( layersGroup , onChangeSpy ) ) ;
216
+ expect ( onChangeSpy ) . to . have . been . calledOnceWith ( { $or : [ ] } ) ;
217
+ } ) ;
218
+ } ) ;
219
+
157
220
describe ( 'schema export' , function ( ) {
158
221
describe ( 'with an analyzed schema' , function ( ) {
159
222
beforeEach ( async function ( ) {
0 commit comments