Skip to content

Commit cc89fdf

Browse files
committed
test: fix complete dot suite
1 parent 08c71f4 commit cc89fdf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { expect } from "chai";
2-
import Vue from "vue";
32
import CircleContainer from "@/components/Circle/CircleContainer.vue";
43
// import VueEllipseProgress from "@/components/VueEllipseProgress.vue";
54
import Circle from "@/components/Circle/Circle.vue";
@@ -15,8 +14,6 @@ describe("#dot", () => {
1514
const size = 500;
1615
const globalDot = "5%";
1716

18-
const calculateThickness = (t) => (t.toString().includes("%") ? (parseFloat(t) * size) / 100 : t);
19-
2017
// TODO: move to container
2118
/* it(`parses property as Number correctly`, () => {
2219
const wrapper = localFactory({ progress, size, dot: dotParser(0) });
@@ -55,7 +52,7 @@ describe("#dot", () => {
5552

5653
it(`calculates and applies correct rotation of the dot container depending on progress`, (done) => {
5754
const wrapper = localFactory(
58-
{ progress, dot: dotParser(5), animation: animationParser("default 0 0") },
55+
{ progress, dot: dotParser(5, size), animation: animationParser("default 0 0") },
5956
CircleContainer
6057
);
6158
const circleDotWrapper = wrapper.findComponent(CircleDot);
@@ -69,7 +66,7 @@ describe("#dot", () => {
6966

7067
it(`applies correct initial rotation of the dot container`, async () => {
7168
const wrapper = localFactory(
72-
{ progress, dot: dotParser(5), animation: animationParser("default 0 1000") },
69+
{ progress, dot: dotParser(5, size), animation: animationParser("default 0 1000") },
7370
CircleContainer
7471
);
7572
const circleDotWrapper = wrapper.findComponent(CircleDot);
@@ -86,7 +83,7 @@ describe("#dot", () => {
8683
const wrapper = localFactory(
8784
{
8885
progress,
89-
dot: dotParser({ size: 10, background: "red", border: "2px solid green" }),
86+
dot: dotParser({ size: 10, background: "red", border: "2px solid green" }, size),
9087
animation: animationParser("default 0 1000"),
9188
},
9289
CircleDot
@@ -97,7 +94,7 @@ describe("#dot", () => {
9794

9895
it(`do not apply custom height to dot`, async () => {
9996
const wrapper = localFactory(
100-
{ progress, dot: dotParser({ size: 10, height: "20px" }), animation: animationParser("default 0 1000") },
97+
{ progress, dot: dotParser({ size: 10, height: "20px" }, size), animation: animationParser("default 0 1000") },
10198
CircleDot
10299
).find("span.ep-circle--progress__dot");
103100
expect(wrapper.element.style.height).to.equal("10px");
@@ -117,18 +114,22 @@ describe("#dot", () => {
117114

118115
for (let i = 0; i < data.length; i++) {
119116
const circleData = data[i];
120-
const wrapper = localFactory({ size, dot: dotParser(globalDot), ...circleData }, CircleContainer);
117+
const wrapper = localFactory({ ...circleData, size, dot: dotParser(circleData.dot, size) }, CircleContainer);
121118
const circleDotSpanWrapper = wrapper.find("span.ep-circle--progress__dot");
122119
const circleDotWrapper = wrapper.findComponent(CircleDot);
123120
const circleWrapper = wrapper.findComponent(Circle);
124-
const parsedDot = dotParser(circleData.dot !== undefined ? circleData.dot : globalDot);
125-
const parsedDotSize = parseFloat(calculateThickness(parsedDot.size));
121+
const parsedDot = dotParser(circleData.dot !== undefined ? circleData.dot : globalDot, size);
122+
const parsedDotSize = parsedDot.size;
126123
const parsedDotColor = parsedDot.backgroundColor || parsedDot.background || parsedDot.color;
127124

128125
it(`renders dot component | #dot = ${circleData.dot}`, () => {
129126
expect(wrapper.findComponent(CircleDot).exists()).to.be.true;
130127
});
131128

129+
it(`renders dot span element | #dot = ${circleData.dot}`, () => {
130+
expect(wrapper.find("span.ep-circle--progress__dot").exists()).to.be.true;
131+
});
132+
132133
it(`applies the height of the dot correctly | #dot = ${circleData.dot}`, () => {
133134
expect(circleDotSpanWrapper.element.style.height).to.equal(`${parsedDotSize}px`);
134135
});

0 commit comments

Comments
 (0)