@osimatic/helpers-js 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/count_down.js +46 -48
- package/date_time.js +0 -1
- package/details_sub_array.js +65 -50
- package/flash_message.js +10 -6
- package/form_date.js +144 -153
- package/form_helper.js +283 -232
- package/google_charts.js +154 -144
- package/google_maps.js +1 -1
- package/import_from_csv.js +198 -160
- package/multi_files_input.js +44 -35
- package/multiple_action_in_table.js +123 -109
- package/package.json +1 -1
- package/paging.js +103 -84
- package/select_all.js +65 -70
- package/sortable_list.js +12 -13
- package/tests/count_down.test.js +131 -352
- package/tests/details_sub_array.test.js +213 -258
- package/tests/flash_message.test.js +21 -153
- package/tests/form_date.test.js +287 -961
- package/tests/form_helper.test.js +553 -673
- package/tests/google_charts.test.js +338 -339
- package/tests/google_maps.test.js +3 -15
- package/tests/import_from_csv.test.js +421 -640
- package/tests/multi_files_input.test.js +305 -737
- package/tests/multiple_action_in_table.test.js +442 -429
- package/tests/open_street_map.test.js +15 -23
- package/tests/paging.test.js +344 -475
- package/tests/select_all.test.js +232 -318
- package/tests/sortable_list.test.js +176 -500
- package/tests/user.test.js +163 -54
- package/user.js +35 -38
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
1
4
|
const { OpenStreetMap } = require('../open_street_map');
|
|
5
|
+
const L = require('leaflet');
|
|
2
6
|
|
|
3
7
|
describe('OpenStreetMap', () => {
|
|
4
8
|
describe('getUrl', () => {
|
|
@@ -299,21 +303,17 @@ describe('OpenStreetMap', () => {
|
|
|
299
303
|
setZoom: jest.fn()
|
|
300
304
|
};
|
|
301
305
|
|
|
302
|
-
// Mock L.latLngBounds
|
|
303
|
-
global.L = {
|
|
304
|
-
latLngBounds: jest.fn((locations) => ({
|
|
305
|
-
_bounds: locations
|
|
306
|
-
}))
|
|
307
|
-
};
|
|
308
|
-
|
|
309
306
|
const locations = [[48.8566, 2.3522], [48.8606, 2.3376]];
|
|
307
|
+
const mockBounds = { _bounds: locations };
|
|
308
|
+
const latLngBoundsSpy = jest.spyOn(L, 'latLngBounds').mockReturnValue(mockBounds);
|
|
309
|
+
|
|
310
310
|
OpenStreetMap.centerMapToLocations(mockMap, locations);
|
|
311
311
|
|
|
312
312
|
expect(mockMap.invalidateSize).toHaveBeenCalledWith(false);
|
|
313
|
-
expect(
|
|
313
|
+
expect(latLngBoundsSpy).toHaveBeenCalledWith(locations);
|
|
314
314
|
expect(mockMap.fitBounds).toHaveBeenCalled();
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
latLngBoundsSpy.mockRestore();
|
|
317
317
|
});
|
|
318
318
|
|
|
319
319
|
test('should not do anything when map is null', () => {
|
|
@@ -346,18 +346,14 @@ describe('OpenStreetMap', () => {
|
|
|
346
346
|
setZoom: jest.fn()
|
|
347
347
|
};
|
|
348
348
|
|
|
349
|
-
global.L = {
|
|
350
|
-
latLngBounds: jest.fn((locations) => ({
|
|
351
|
-
_bounds: locations
|
|
352
|
-
}))
|
|
353
|
-
};
|
|
354
|
-
|
|
355
349
|
const locations = [[48.8566, 2.3522]];
|
|
350
|
+
const latLngBoundsSpy = jest.spyOn(L, 'latLngBounds').mockReturnValue({ _bounds: locations });
|
|
351
|
+
|
|
356
352
|
OpenStreetMap.centerMapToLocations(mockMap, locations, [20, 20], 18);
|
|
357
353
|
|
|
358
354
|
expect(mockMap.setZoom).toHaveBeenCalledWith(18);
|
|
359
355
|
|
|
360
|
-
|
|
356
|
+
latLngBoundsSpy.mockRestore();
|
|
361
357
|
});
|
|
362
358
|
|
|
363
359
|
test('should use custom padding', () => {
|
|
@@ -368,13 +364,9 @@ describe('OpenStreetMap', () => {
|
|
|
368
364
|
setZoom: jest.fn()
|
|
369
365
|
};
|
|
370
366
|
|
|
371
|
-
global.L = {
|
|
372
|
-
latLngBounds: jest.fn((locations) => ({
|
|
373
|
-
_bounds: locations
|
|
374
|
-
}))
|
|
375
|
-
};
|
|
376
|
-
|
|
377
367
|
const locations = [[48.8566, 2.3522]];
|
|
368
|
+
const latLngBoundsSpy = jest.spyOn(L, 'latLngBounds').mockReturnValue({ _bounds: locations });
|
|
369
|
+
|
|
378
370
|
OpenStreetMap.centerMapToLocations(mockMap, locations, [50, 50]);
|
|
379
371
|
|
|
380
372
|
expect(mockMap.fitBounds).toHaveBeenCalledWith(
|
|
@@ -382,7 +374,7 @@ describe('OpenStreetMap', () => {
|
|
|
382
374
|
{ padding: [50, 50] }
|
|
383
375
|
);
|
|
384
376
|
|
|
385
|
-
|
|
377
|
+
latLngBoundsSpy.mockRestore();
|
|
386
378
|
});
|
|
387
379
|
});
|
|
388
380
|
});
|