Skip to content

Commit f19d30a

Browse files
committed
test: add hideLegend tests
1 parent 885fbda commit f19d30a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
File renamed without changes.

Diff for: src/App.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@
5757
:legend="-123.1"
5858
font-size="2rem"
5959
>
60-
<template #legend-caption>
61-
<p>hello</p>
60+
<template #legend>
61+
<img style="width: 50px; height: 50px" src="../public/vue_ellipse.png" />
6262
</template>
63+
<!-- <template #legend-caption>
64+
<p>hello</p>
65+
</template>-->
6366
</ve-progress>
6467
</div>
6568
</div>

Diff for: tests/unit/container.spec.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import CircleContainer from "@/components/Circle/CircleContainer.vue";
55
import Counter from "@/components/Counter.vue";
66
import { animationParser, dotParser, dashParser, lineModeParser, linePositionParser } from "@/components/optionsParser";
77
import props from "@/components/interface";
8-
import { defaultCounterTick } from "@/../tests/helper";
8+
import { defaultCounterTick, wait } from "@/../tests/helper";
9+
import { nextTick } from "vue";
910

1011
const factory = (propsData, slots = {}) => {
1112
return mount(VueEllipseProgress, {
@@ -74,6 +75,25 @@ describe("[ EllipseProgressContainer.vue ]", () => {
7475
expect(wrapper.vm.progress).to.equal(progress);
7576
});
7677
});
78+
describe("#hideLegend", () => {
79+
const wrapper = factory({ hideLegend: true });
80+
const legendWrapper = wrapper.find(".ep-legend--value");
81+
82+
it("adds hide class to the legend element", async () => {
83+
expect(legendWrapper.classes()).to.be.an("array").that.include("ep-hidden");
84+
});
85+
86+
it("applies height to the style attribute", () => {
87+
// anything we can test about it as jsdom does not render actual layout
88+
expect(legendWrapper.element.style).to.be.an("object").that.have.property("height");
89+
});
90+
91+
it("removes the hide class from the legend element, if false", async () => {
92+
await wrapper.setProps({ hideLegend: false });
93+
await nextTick();
94+
expect(legendWrapper.classes()).to.be.an("array").that.not.include("ep-hidden");
95+
});
96+
});
7797
describe("#noData", () => {
7898
const wrapper = factory({ noData: true });
7999
it("hides the legend, if true", () => {

0 commit comments

Comments
 (0)