Skip to content

Commit b84879c

Browse files
committed
Add tests for LCircleMarker component
1 parent 9a60975 commit b84879c

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { getWrapperWithMap } from '@/tests/test-helpers';
2+
import { testCircleFunctionality } from '@/tests/mixin-tests/circle-tests';
3+
import LCircleMarker from '@/components/LCircleMarker.vue';
4+
import L from 'leaflet';
5+
6+
describe('component: LCircleMarker.vue', () => {
7+
test('LCircleMarker.vue has a mapObject', () => {
8+
const { wrapper } = getWrapperWithMap(LCircleMarker);
9+
10+
expect(wrapper.vm.mapObject).toBeDefined();
11+
});
12+
13+
// Circle mixin
14+
15+
testCircleFunctionality(LCircleMarker, 'LCircleMarker.vue');
16+
17+
// latLng property
18+
19+
test('LCircleMarker.vue accepts and uses latLng prop as an array', () => {
20+
const latLng = [3.14, 2.79];
21+
const { wrapper } = getWrapperWithMap(LCircleMarker, { latLng });
22+
23+
expect(wrapper.vm.mapObject.getLatLng()).toEqual(L.latLng(latLng));
24+
});
25+
26+
test('LCircleMarker.vue accepts and uses latLng prop as a Leaflet object', () => {
27+
const latLng = L.latLng([3.14, 2.79]);
28+
const { wrapper } = getWrapperWithMap(LCircleMarker, { latLng });
29+
30+
expect(wrapper.vm.mapObject.getLatLng()).toEqual(latLng);
31+
});
32+
33+
test('LCircleMarker.vue updates the mapObject latLng when prop is changed to an array', async () => {
34+
const { wrapper } = getWrapperWithMap(LCircleMarker, { latLng: [11, 22] });
35+
36+
const newLatLng = [1, 1];
37+
wrapper.setProps({ latLng: newLatLng });
38+
await wrapper.vm.$nextTick();
39+
40+
expect(wrapper.vm.mapObject.getLatLng()).toEqual(L.latLng(newLatLng));
41+
});
42+
43+
test('LCircleMarker.vue updates the mapObject latLng when prop is changed to an object', async () => {
44+
const { wrapper } = getWrapperWithMap(LCircleMarker, { latLng: [11, 22] });
45+
46+
const newLatLng = L.latLng([1, 1]);
47+
wrapper.setProps({ latLng: newLatLng });
48+
await wrapper.vm.$nextTick();
49+
50+
expect(wrapper.vm.mapObject.getLatLng()).toEqual(newLatLng);
51+
});
52+
53+
// Pane
54+
55+
test('LCircleMarker.vue accepts and uses pane prop', () => {
56+
const pane = 'overlayPane';
57+
const { wrapper } = getWrapperWithMap(LCircleMarker, { pane });
58+
59+
expect(wrapper.vm.mapObject.options.pane).toEqual(pane);
60+
});
61+
62+
// Slot
63+
64+
test('LCircleMarker.vue displays text from its default slot', async () => {
65+
const markerText = 'O hai, Marker!';
66+
const { wrapper } = getWrapperWithMap(LCircleMarker, {
67+
latLng: [0, 0]
68+
}, {
69+
slots: {
70+
default: markerText
71+
}
72+
});
73+
await wrapper.vm.$nextTick();
74+
75+
expect(wrapper.text()).toEqual(markerText);
76+
});
77+
});

0 commit comments

Comments
 (0)