Skip to content

Commit f99d7c0

Browse files
committed
Tests - Add VueUiWheel component test
1 parent 2385f10 commit f99d7c0

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

cypress/fixtures/vdui-components.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,16 @@ export const components = [
13591359
{
13601360
name: 'VueUiWheel',
13611361
dataset: { percentage: 50 },
1362+
config: {
1363+
style: {
1364+
chart: {
1365+
title: {
1366+
text: 'Title',
1367+
subtitle: { text: 'Subtitle' }
1368+
}
1369+
}
1370+
}
1371+
},
13621372
wrapperClass: '.vue-ui-wheel'
13631373
},
13641374
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ const { dataset, config } = components.find(c => c.name === 'VueUiTiremarks');
77
describe('<VueUiTiremarks />', () => {
88

99
it('renders', () => {
10+
cy.spy(window, 'requestAnimationFrame').as('rafSpy');
1011
cy.mount(VueUiTiremarks, {
1112
props: {
1213
dataset,
1314
config
1415
}
1516
}).then(() => {
17+
18+
cy.log('Animating');
19+
cy.get('@rafSpy').should('have.been.called');
1620

1721
testCommonFeatures({
1822
userOptions: true,

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import VueUiWheel from "./vue-ui-wheel.vue";
2+
import { components } from "../../cypress/fixtures/vdui-components";
3+
import { testCommonFeatures } from "../../cypress/fixtures";
4+
5+
const { dataset, config } = components.find(c => c.name === 'VueUiWheel');
6+
7+
describe('<VueUiWheel />', () => {
8+
9+
it('renders', () => {
10+
cy.viewport(500, 560);
11+
cy.spy(window, 'requestAnimationFrame').as('rafSpy');
12+
13+
cy.mount(VueUiWheel, {
14+
props: {
15+
dataset,
16+
config
17+
}
18+
}).then(() => {
19+
20+
cy.log('Animating');
21+
cy.get('@rafSpy').should('have.been.called');
22+
23+
testCommonFeatures({
24+
userOptions: true,
25+
title: true,
26+
subtitle: true
27+
});
28+
29+
cy.log('ticks');
30+
cy.get('[data-cy="wheel-tick"]').should('exist').and('be.visible').and('have.length', 100);
31+
32+
cy.log('inner circle');
33+
cy.get('[data-cy="inner-circle"]').should('exist').and('be.visible');
34+
35+
cy.log('data label');
36+
cy.get('[data-cy="data-label"]').should('exist').and('be.visible').and('contain', dataset.percentage).and('contain', '%');
37+
});
38+
});
39+
});

src/components/vue-ui-wheel.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ defineExpose({
325325
</foreignObject>
326326

327327

328-
<line
328+
<line
329+
data-cy="wheel-tick"
329330
v-for="(tick, i) in ticks"
330331
:x1="tick.x1"
331332
:x2="tick.x2"
@@ -336,7 +337,8 @@ defineExpose({
336337
:stroke-linecap="FINAL_CONFIG.style.chart.layout.wheel.ticks.rounded ? 'round' : 'butt'"
337338
:class="{ 'vue-ui-tick-animated': FINAL_CONFIG.style.chart.animation.use && i <= activeValue }"
338339
/>
339-
<circle
340+
<circle
341+
data-cy="inner-circle"
340342
v-if="FINAL_CONFIG.style.chart.layout.innerCircle.show"
341343
:cx="wheel.centerX"
342344
:cy="wheel.centerY"
@@ -346,6 +348,7 @@ defineExpose({
346348
fill="none"
347349
/>
348350
<text
351+
data-cy="data-label"
349352
v-if="FINAL_CONFIG.style.chart.layout.percentage.show"
350353
:x="wheel.centerX"
351354
:y="wheel.centerY + baseLabelFontSize / 3"

0 commit comments

Comments
 (0)