Skip to content

Commit e8da1be

Browse files
committed
fix: refactor #dot tests
1 parent f3024d6 commit e8da1be

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

tests/unit/circle/circle-dot.spec.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ import { expect } from "chai";
22
import CircleContainer from "@/components/Circle/CircleContainer.vue";
33
import Circle from "@/components/Circle/Circle.vue";
44
import CircleDot from "@/components/Circle/CircleDot.vue";
5-
import { animationParser, dotParser } from "@/components/optionsParser";
6-
import { factory } from "@/../tests/helper";
5+
import { dotParser } from "@/components/optionsParser";
6+
import { factory, parseRawOptions } from "@/../tests/helper";
77

8-
const localFactory = (props = {}, container = Circle) => factory({ container, props });
8+
const localFactory = (props = {}, container = CircleContainer) => factory({ container, props: parseRawOptions(props) });
99

1010
describe("#dot", () => {
1111
const progress = 50;
1212
const thickness = 5;
1313
const size = 500;
1414
const globalDot = "5%";
1515

16+
it("does not renders dot component with 0 size", () => {
17+
expect(localFactory().findComponent(CircleDot).exists()).to.be.false;
18+
});
19+
1620
it("applies default dot value correctly", () => {
17-
const wrapper = localFactory({}, CircleContainer);
21+
const wrapper = localFactory({});
1822
const dotSpanWrapper = wrapper.find(".ep-circle--progress__dot");
1923

2024
expect(dotSpanWrapper.element.style.width).to.equal("0px");
@@ -23,10 +27,7 @@ describe("#dot", () => {
2327
});
2428

2529
it(`calculates and applies correct rotation of the dot container depending on progress`, (done) => {
26-
const wrapper = localFactory(
27-
{ progress, dot: dotParser(5, size), animation: animationParser("default 0 0") },
28-
CircleContainer
29-
);
30+
const wrapper = localFactory({ progress, dot: 5, animation: "default 0 0" });
3031
const circleDotWrapper = wrapper.findComponent(CircleDot);
3132
const rotationStart = wrapper.props("options").angle + 90;
3233
const rotation = rotationStart + (progress * 360) / 100;
@@ -37,10 +38,7 @@ describe("#dot", () => {
3738
});
3839

3940
it(`applies correct initial rotation of the dot container`, async () => {
40-
const wrapper = localFactory(
41-
{ progress, dot: dotParser(5, size), animation: animationParser("default 0 1000") },
42-
CircleContainer
43-
);
41+
const wrapper = localFactory({ progress, dot: 5, animation: "default 0 1000" });
4442
const circleDotWrapper = wrapper.findComponent(CircleDot);
4543
const angle = wrapper.props("options").angle;
4644
const rotationStart = angle + 90;
@@ -55,8 +53,8 @@ describe("#dot", () => {
5553
const wrapper = localFactory(
5654
{
5755
progress,
58-
dot: dotParser({ size: 10, background: "red", border: "2px solid green" }, size),
59-
animation: animationParser("default 0 1000"),
56+
dot: { size: 10, background: "red", border: "2px solid green" },
57+
animation: "default 0 1000",
6058
},
6159
CircleDot
6260
).find("span.ep-circle--progress__dot");
@@ -66,7 +64,7 @@ describe("#dot", () => {
6664

6765
it(`do not apply custom height to dot`, async () => {
6866
const wrapper = localFactory(
69-
{ progress, dot: dotParser({ size: 10, height: "20px" }, size), animation: animationParser("default 0 1000") },
67+
{ progress, dot: { size: 10, height: "20px" }, animation: "default 0 1000" },
7068
CircleDot
7169
).find("span.ep-circle--progress__dot");
7270
expect(wrapper.element.style.height).to.equal("10px");
@@ -86,7 +84,7 @@ describe("#dot", () => {
8684

8785
for (let i = 0; i < data.length; i++) {
8886
const circleData = data[i];
89-
const wrapper = localFactory({ ...circleData, size, dot: dotParser(circleData.dot, size) }, CircleContainer);
87+
const wrapper = localFactory({ ...circleData, size, dot: circleData.dot });
9088
const circleDotSpanWrapper = wrapper.find("span.ep-circle--progress__dot");
9189
const circleDotWrapper = wrapper.findComponent(CircleDot);
9290
const circleWrapper = wrapper.findComponent(Circle);

0 commit comments

Comments
 (0)