Skip to content

Commit f5c312a

Browse files
committed
Tests - Improve VueUiQuadrant component test
1 parent 3d1616e commit f5c312a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/components/vue-ui-quadrant.cy.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,41 @@ describe('<VueUiQuadrant />', () => {
9494
cy.get('[data-cy="plot-label"]').should('exist').and('be.visible').and('have.length', dataset[0].series.length);
9595
});
9696
});
97+
98+
it('emits', () => {
99+
cy.spy(window, 'requestAnimationFrame').as('rafSpy');
100+
cy.mount(VueUiQuadrant, {
101+
props: {
102+
dataset,
103+
config
104+
}
105+
}).then(({ wrapper }) => {
106+
cy.log('@selectPlot');
107+
cy.get('[data-cy="atom-shape"]').first().click().then(() => {
108+
expect(wrapper.emitted('selectPlot')[0][0]).to.have.keys(
109+
'category',
110+
'shape',
111+
'itemName',
112+
'x',
113+
'y',
114+
'quadrantSide',
115+
'sideName'
116+
);
117+
});
118+
119+
cy.log('@selectSide');
120+
cy.get('[data-cy="side-trap-tl"]').click({ force: true }).then(() => {
121+
expect(wrapper.emitted('selectSide')[0][0]).to.have.keys('items', 'quadrantSide', 'sideName');
122+
expect(wrapper.emitted('selectSide')[0][0].quadrantSide).to.equal('tl');
123+
expect(wrapper.emitted('selectSide')[0][0].sideName).to.equal('TL');
124+
cy.get('@rafSpy').should('have.been.called');
125+
});
126+
127+
cy.log('@selectLegend');
128+
cy.get('[data-cy="legend-item"]').first().click().then(() => {
129+
expect(wrapper.emitted('selectLegend')).to.exist;
130+
});
131+
});
132+
});
97133
});
98134

src/components/vue-ui-quadrant.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ defineExpose({
15371537
@clickMarker="({legend}) => segregate(legend.id)"
15381538
>
15391539
<template #item="{ legend }">
1540-
<div data-cy-legend-item @click="segregate(legend.id)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
1540+
<div data-cy="legend-item" @click="segregate(legend.id)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
15411541
{{ legend.name }}
15421542
</div>
15431543
</template>

0 commit comments

Comments
 (0)