Skip to content

Commit 8d5e186

Browse files
committed
Tests - Add VueUiWordCloud component test
1 parent f99d7c0 commit 8d5e186

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

cypress/fixtures/vdui-components.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,16 @@ export const components = [
14841484
{
14851485
name: 'VueUiWordCloud',
14861486
dataset: 'Lorem ipsum dolor sit amet Lorem Lorem Lorem sit sit ipsum',
1487+
config: {
1488+
style: {
1489+
chart: {
1490+
title: {
1491+
text: 'Title',
1492+
subtitle: { text: 'Subtitle' }
1493+
}
1494+
}
1495+
}
1496+
},
14871497
wrapperClass: '.vue-ui-word-cloud'
14881498
},
14891499
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import VueUiWordCloud from "./vue-ui-word-cloud.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 === 'VueUiWordCloud');
6+
7+
describe('<VueUiWordCloud />', () => {
8+
9+
it('renders', () => {
10+
cy.viewport(500, 570);
11+
cy.mount(VueUiWordCloud, {
12+
props: {
13+
dataset,
14+
config
15+
}
16+
}).then(() => {
17+
18+
testCommonFeatures({
19+
userOptions: true,
20+
title: true,
21+
subtitle: true,
22+
dataTable: true,
23+
tooltipCallback: () => {
24+
cy.get('[data-cy="datapoint-word"]').first().trigger('mouseover', { force: true })
25+
}
26+
});
27+
28+
cy.get('[data-cy="datapoint-word"]').should('exist').and('be.visible').and('have.length', 5);
29+
});
30+
});
31+
});

src/components/vue-ui-word-cloud.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ function useTooltip(word) {
530530
<g
531531
:transform="`translate(${(svg.width <= 0 ? 10 : svg.width) / 2}, ${(svg.height <= 0 ? 10 : svg.height) / 2})`">
532532
<g v-for="(word, index) in positionedWords">
533-
<text
533+
<text
534+
data-cy="datapoint-word"
534535
:fill="word.color"
535536
:font-weight="FINAL_CONFIG.style.chart.words.bold ? 'bold' : 'normal'" :key="index"
536537
:x="word.x" :y="word.y" :font-size="word.fontSize"

0 commit comments

Comments
 (0)