Skip to content

Commit cc2c9f3

Browse files
committed
Add tests to ensure legitimate falsy values can be set
1 parent b84879c commit cc2c9f3

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

tests/mixin-tests/path-tests.js

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const testPathFunctionality = (component, componentName = 'it') => {
1616
expect(wrapper.vm.mapObject.options.stroke).toBeFalsy();
1717
});
1818

19-
test(`${componentName} updates stroke when prop changes`, async () => {
19+
test(`${componentName} updates stroke when prop changes to false`, async () => {
2020
const { wrapper } = getWrapperWithMap(component, { stroke: true });
2121

2222
wrapper.setProps({ stroke: false });
@@ -25,7 +25,16 @@ export const testPathFunctionality = (component, componentName = 'it') => {
2525
expect(wrapper.vm.mapObject.options.stroke).toBeFalsy();
2626
});
2727

28-
test(`${componentName} updates stroke using setStroke`, async () => {
28+
test(`${componentName} updates stroke when prop changes to true`, async () => {
29+
const { wrapper } = getWrapperWithMap(component, { stroke: false });
30+
31+
wrapper.setProps({ stroke: true });
32+
await wrapper.vm.$nextTick();
33+
34+
expect(wrapper.vm.mapObject.options.stroke).toBeTruthy();
35+
});
36+
37+
test(`${componentName} updates stroke to false using setStroke`, async () => {
2938
const { wrapper } = getWrapperWithMap(component, { stroke: true });
3039

3140
wrapper.vm.setStroke(false);
@@ -34,6 +43,15 @@ export const testPathFunctionality = (component, componentName = 'it') => {
3443
expect(wrapper.vm.mapObject.options.stroke).toBeFalsy();
3544
});
3645

46+
test(`${componentName} updates stroke to true using setStroke`, async () => {
47+
const { wrapper } = getWrapperWithMap(component, { stroke: false });
48+
49+
wrapper.vm.setStroke(true);
50+
await wrapper.vm.$nextTick();
51+
52+
expect(wrapper.vm.mapObject.options.stroke).toBeTruthy();
53+
});
54+
3755
// Color
3856

3957
test(`${componentName} accepts and uses color prop`, () => {
@@ -121,6 +139,16 @@ export const testPathFunctionality = (component, componentName = 'it') => {
121139
expect(wrapper.vm.mapObject.options.opacity).toEqual(newOpacity);
122140
});
123141

142+
test(`${componentName} can set opacity to zero`, async () => {
143+
const { wrapper } = getWrapperWithMap(component, { opacity: 0.2 });
144+
145+
const newOpacity = 0;
146+
wrapper.vm.setOpacity(newOpacity);
147+
await wrapper.vm.$nextTick();
148+
149+
expect(wrapper.vm.mapObject.options.opacity).toEqual(newOpacity);
150+
});
151+
124152
// LineCap
125153

126154
test(`${componentName} accepts and uses lineCap prop`, () => {
@@ -251,7 +279,7 @@ export const testPathFunctionality = (component, componentName = 'it') => {
251279
expect(wrapper.vm.mapObject.options.fill).toBeFalsy();
252280
});
253281

254-
test(`${componentName} updates fill when prop changes`, async () => {
282+
test(`${componentName} updates fill when prop changes to false`, async () => {
255283
const { wrapper } = getWrapperWithMap(component, { fill: true });
256284

257285
wrapper.setProps({ fill: false });
@@ -260,7 +288,16 @@ export const testPathFunctionality = (component, componentName = 'it') => {
260288
expect(wrapper.vm.mapObject.options.fill).toBeFalsy();
261289
});
262290

263-
test(`${componentName} updates fill using setFill`, async () => {
291+
test(`${componentName} updates fill when prop changes to true`, async () => {
292+
const { wrapper } = getWrapperWithMap(component, { fill: false });
293+
294+
wrapper.setProps({ fill: true });
295+
await wrapper.vm.$nextTick();
296+
297+
expect(wrapper.vm.mapObject.options.fill).toBeTruthy();
298+
});
299+
300+
test(`${componentName} updates fill to false using setFill`, async () => {
264301
const { wrapper } = getWrapperWithMap(component, { fill: true });
265302

266303
wrapper.vm.setFill(false);
@@ -269,6 +306,15 @@ export const testPathFunctionality = (component, componentName = 'it') => {
269306
expect(wrapper.vm.mapObject.options.fill).toBeFalsy();
270307
});
271308

309+
test(`${componentName} updates fill to true using setFill`, async () => {
310+
const { wrapper } = getWrapperWithMap(component, { fill: false });
311+
312+
wrapper.vm.setFill(true);
313+
await wrapper.vm.$nextTick();
314+
315+
expect(wrapper.vm.mapObject.options.fill).toBeTruthy();
316+
});
317+
272318
// FillColor
273319

274320
test(`${componentName} accepts and uses fillColor prop`, () => {
@@ -327,6 +373,16 @@ export const testPathFunctionality = (component, componentName = 'it') => {
327373
expect(wrapper.vm.mapObject.options.fillOpacity).toEqual(newFillOpacity);
328374
});
329375

376+
test(`${componentName} can set fillOpacity to zero`, async () => {
377+
const { wrapper } = getWrapperWithMap(component, { fillOpacity: 0.2 });
378+
379+
const newFillOpacity = 0;
380+
wrapper.vm.setFillOpacity(newFillOpacity);
381+
await wrapper.vm.$nextTick();
382+
383+
expect(wrapper.vm.mapObject.options.fillOpacity).toEqual(newFillOpacity);
384+
});
385+
330386
// FillRule
331387

332388
test(`${componentName} accepts and uses fillRule prop`, () => {

0 commit comments

Comments
 (0)