Skip to content

Commit 3b4de2c

Browse files
committed
Tests - Improve VueUiNestedDonuts component test
1 parent 87e2265 commit 3b4de2c

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

src/atoms/Shape.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const d = computed(() => {
8484
<template>
8585
<g data-cy="atom-shape">
8686
<circle
87-
class="legend-shape-circle"
87+
class="vdui-shape-circle"
8888
v-if="config && config.points === 1"
8989
:cx="plot.x"
9090
:cy="plot.y"
@@ -97,7 +97,7 @@ const d = computed(() => {
9797
@click="emit('click')"
9898
/>
9999
<path
100-
class="legend-shape-polygon"
100+
class="vdui-shape-polygon"
101101
v-if="config && config.points >= limit"
102102
:d="d"
103103
:fill="color"
@@ -108,7 +108,7 @@ const d = computed(() => {
108108
@click="emit('click')"
109109
/>
110110
<polygon
111-
class="legend-shape-star"
111+
class="vdui-shape-star"
112112
v-if="starPoints"
113113
:points="starPoints"
114114
:fill="color"

src/components/vue-ui-nested-donuts.cy.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,51 @@ describe('<VueUiNestedDonuts />', () => {
4545
cy.get('[data-cy="datapoint-value"]').should('exist').and('be.visible').and('have.length', dataset.map(d => d.series.length).reduce((a, b) => a + b, 0));
4646
});
4747
});
48+
49+
it('emits', () => {
50+
cy.mount(VueUiNestedDonuts, {
51+
props: {
52+
dataset,
53+
config
54+
}
55+
}).then(({ wrapper }) => {
56+
cy.log('@selectLegend');
57+
cy.get('[data-cy="legend-item"]').first().click({ force: true }).then(() => {
58+
expect(wrapper.emitted('selectLegend')).to.exist;
59+
});
60+
61+
cy.log('@selectDatapoint');
62+
cy.get('[data-cy="tooltip-trap"]').first().click({ force: true }).then(() => {
63+
expect(wrapper.emitted('selectDatapoint')).to.exist;
64+
expect(wrapper.emitted('selectDatapoint')[0][0]).to.have.keys('datapoint', 'index');
65+
expect(wrapper.emitted('selectDatapoint')[0][0].index).to.equal(0);
66+
expect(wrapper.emitted('selectDatapoint')[0][0].datapoint).to.have.keys(
67+
'absoluteValues',
68+
'arcOf',
69+
'arcOfId',
70+
'arcSlice',
71+
'center',
72+
'color',
73+
'cx',
74+
'cy',
75+
'datasetIndex',
76+
'endX',
77+
'endY',
78+
'firstSeparator',
79+
'id',
80+
'name',
81+
'path',
82+
'proportion',
83+
'ratio',
84+
'separator',
85+
'seriesIndex',
86+
'startX',
87+
'startY',
88+
'value'
89+
);
90+
expect(wrapper.emitted('selectDatapoint')[0][0].datapoint.datasetIndex).to.equal(0);
91+
expect(wrapper.emitted('selectDatapoint')[0][0].datapoint.seriesIndex).to.equal(0);
92+
})
93+
});
94+
});
4895
});

src/components/vue-ui-nested-donuts.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ defineExpose({
10751075
</div>
10761076
</template>
10771077
<template #item="{ legend, index }">
1078-
<div :data-cy="`legend-item-${index}`" @click="segregateDonut(legend)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
1078+
<div data-cy="legend-item" @click="segregateDonut(legend)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
10791079
{{ legend.name }}: {{ applyDataLabel(
10801080
FINAL_CONFIG.style.chart.layout.labels.dataLabels.formatter,
10811081
legend.value,

src/components/vue-ui-parallel-coordinate-plot.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('<VueUiParallelCoordinatePlot />', () => {
6060
});
6161

6262
cy.log('@selectDatapoint');
63-
cy.get('.legend-shape-circle').first().click({ force: true }).then(() => {
63+
cy.get('.vdui-shape-circle').first().click({ force: true }).then(() => {
6464
expect(wrapper.emitted('selectDatapoint')).to.exist;
6565
expect(wrapper.emitted('selectDatapoint')[0][0]).to.have.keys(
6666
'axisIndex',

0 commit comments

Comments
 (0)