Skip to content

Commit d32d012

Browse files
committed
Tests - Slicer & SlicerPreview - Improve component tests
1 parent 1855232 commit d32d012

File tree

2 files changed

+456
-6
lines changed

2 files changed

+456
-6
lines changed

src/atoms/Slicer.cy.js

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("<Slicer />", () => {
1212
show: true,
1313
color: "#42d392",
1414
fontSize: 12,
15-
useResetSlot: true,
15+
useResetSlot: false,
1616
highlightColor: "#3A3A3A",
1717
startIndex: null,
1818
endIndex: 5,
@@ -40,6 +40,22 @@ describe("<Slicer />", () => {
4040
const slicerStep = ref(1);
4141
const slicer = reactive({ start: 0, end: ds.length });
4242

43+
const events = reactive({
44+
futureStart: null,
45+
futureEnd: null,
46+
updateStart: null,
47+
updateEnd: null,
48+
reset: false,
49+
trapMouse: null,
50+
});
51+
52+
const onFutureStart = (v) => (events.futureStart = v);
53+
const onFutureEnd = (v) => (events.futureEnd = v);
54+
const onUpdateStart = (v) => (events.updateStart = v);
55+
const onUpdateEnd = (v) => (events.updateEnd = v);
56+
const onReset = () => (events.reset = true);
57+
const onTrapMouse = (v) => (events.trapMouse = v);
58+
4359
return cy.mount({
4460
components: { Slicer },
4561
setup() {
@@ -48,7 +64,14 @@ describe("<Slicer />", () => {
4864
maxLength,
4965
slicerStep,
5066
slicer,
51-
minimap: ds
67+
minimap: ds,
68+
events,
69+
onFutureStart,
70+
onFutureEnd,
71+
onUpdateStart,
72+
onUpdateEnd,
73+
onReset,
74+
onTrapMouse,
5275
};
5376
},
5477
template: `
@@ -76,12 +99,16 @@ describe("<Slicer />", () => {
7699
:refreshEndPoint="FINAL_CONFIG.style.chart.zoom.endIndex !== null ? FINAL_CONFIG.style.chart.zoom.endIndex + 1 : maxLength"
77100
:enableRangeHandles="FINAL_CONFIG.style.chart.zoom.enableRangeHandles"
78101
:enableSelectionDrag="FINAL_CONFIG.style.chart.zoom.enableSelectionDrag"
102+
@futureStart="onFutureStart"
103+
@futureEnd="onFutureEnd"
104+
@update:start="onUpdateStart"
105+
@update:end="onUpdateEnd"
106+
@reset="onReset"
107+
@trapMouse="onTrapMouse"
79108
/>
80109
</div>
81110
`,
82-
}).then(({ wrapper }) => {
83-
return wrapper
84-
})
111+
}).then(({ wrapper }) => wrapper);
85112
}
86113

87114
it('shows start & end labels on hover', () => {
@@ -200,5 +227,23 @@ describe("<Slicer />", () => {
200227
cy.get('[data-cy="slicer-label-left"]').should('not.be.visible')
201228
cy.get('[data-cy="slicer-label-right"]').should('not.be.visible')
202229
})
203-
})
230+
});
231+
232+
it("emits trapMouse with the hovered trap index and null on mouseleave", () => {
233+
mountSlicer().then((cmp) => {
234+
const ev = cmp.vm.events;
235+
236+
cy.get('[data-cy="minimap"] svg [style*="pointer-events: all"]')
237+
.eq(5)
238+
.trigger("mouseenter", { force: true });
239+
240+
cy.wrap(ev).its("trapMouse").should("eq", 5);
241+
242+
cy.get('[data-cy="minimap"] svg [style*="pointer-events: all"]')
243+
.eq(5)
244+
.trigger("mouseleave", { force: true });
245+
246+
cy.wrap(ev).its("trapMouse").should("eq", null);
247+
});
248+
});
204249
});

0 commit comments

Comments
 (0)