Skip to content

Commit ac9a2ea

Browse files
committed
test: add dot default value test
1 parent eca5372 commit ac9a2ea

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

tests/helper.js

+2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ const mockProps = {
4747
determinate: false,
4848
dot: {
4949
size: 0,
50+
color: "white",
5051
},
5152
globalDot: {
5253
size: 0,
54+
color: "white",
5355
},
5456
reverse: false,
5557
legendFormatter: null,

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

+7-34
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,22 @@ import CircleDot from "@/components/Circle/CircleDot.vue";
55
import { animationParser, dotParser } from "@/components/optionsParser";
66
import { factory } from "@/../tests/helper";
77

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

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

16-
// TODO: move to container
17-
/* it(`parses property as Number correctly`, () => {
18-
const wrapper = localFactory({ progress, size, dot: dotParser(0) });
19-
expect(wrapper.vm.parsedDot.size).to.equal("0");
20-
expect(wrapper.vm.parsedDot.color).to.equal("white");
21-
});
22-
it(`parses property as String correctly`, () => {
23-
const wrapper = localFactory({ progress, size, dot: dotParser("5% red") });
24-
expect(wrapper.vm.parsedDot.size).to.equal("5%");
25-
expect(wrapper.vm.parsedDot.color).to.equal("red");
26-
});
27-
it(`parses property as Object correctly`, () => {
28-
const wrapper = localFactory({ progress, size, dot: dotParser({ size: 10, backgroundColor: "green" }) });
29-
expect(wrapper.vm.parsedDot.size).to.equal(10);
30-
expect(wrapper.vm.parsedDot.color).to.equal("white");
31-
expect(wrapper.vm.parsedDot.backgroundColor).to.equal("green");
32-
});
16+
it("applies default dot value correctly", () => {
17+
const wrapper = localFactory({}, CircleContainer);
18+
const dotSpanWrapper = wrapper.find(".ep-circle--progress__dot");
3319

34-
it(`converts the size percent value to pixel correctly`, () => {
35-
const dot = "5%";
36-
const wrapper = localFactory({ progress, size, dot: dotParser(dot) });
37-
const dotPixelSize = calculateThickness(dot);
38-
expect(wrapper.vm.dotSize).to.equal(dotPixelSize);
20+
expect(dotSpanWrapper.element.style.width).to.equal("0px");
21+
expect(dotSpanWrapper.element.style.height).to.equal("0px");
22+
expect(dotSpanWrapper.element.style.backgroundColor).to.equal("white");
3923
});
40-
it("applies default value correctly", () => {
41-
const wrapper = factory({ progress }, VueEllipseProgress);
42-
const circleWrapper = wrapper.findComponent(Circle);
43-
const circleContainerWrapper = wrapper.findComponent(CircleContainer);
44-
45-
expect(wrapper.props("dot")).to.equal(0);
46-
expect(circleContainerWrapper.props("dot")).to.equal(0);
47-
expect(circleWrapper.vm.parsedDot.size).to.equal("0");
48-
expect(circleWrapper.vm.parsedDot.color).to.equal("white");
49-
expect(circleWrapper.vm.dotSize).to.equal(0);
50-
}); */
5124

5225
it(`calculates and applies correct rotation of the dot container depending on progress`, (done) => {
5326
const wrapper = localFactory(

tests/unit/container.spec.js

+40-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe("[ EllipseProgressContainer.vue ]", () => {
106106
expect(spanWrapper.classes()).to.include("applied-class");
107107
});
108108
});
109-
describe("#slots", () => {
109+
/* describe("#slots", () => {
110110
describe("#legend-value", () => {
111111
it("renders provided slot content", () => {
112112
const wrapper = mount(VueEllipseProgress, {
@@ -155,7 +155,7 @@ describe("[ EllipseProgressContainer.vue ]", () => {
155155
expect(wrapper.findComponent(Counter).findAll("span")).to.have.lengthOf(2);
156156
});
157157
});
158-
});
158+
}); */
159159
describe("#data", () => {
160160
const data = [
161161
{ progress: 25, color: "red" },
@@ -223,4 +223,42 @@ describe("[ EllipseProgressContainer.vue ]", () => {
223223
});
224224
});
225225
});
226+
describe("Options parsers", () => {
227+
describe("#dot parser", () => {
228+
it(`parses property as Number correctly`, () => {
229+
const parsedDot = dotParser(0);
230+
expect(parsedDot.size).to.equal("0");
231+
expect(parsedDot.color).to.equal("white");
232+
});
233+
it(`parses property as String correctly`, () => {
234+
const wrapper = localFactory({ progress, size, dot: dotParser("5% red") });
235+
expect(wrapper.vm.parsedDot.size).to.equal("5%");
236+
expect(wrapper.vm.parsedDot.color).to.equal("red");
237+
});
238+
it(`parses property as Object correctly`, () => {
239+
const wrapper = localFactory({ progress, size, dot: dotParser({ size: 10, backgroundColor: "green" }) });
240+
expect(wrapper.vm.parsedDot.size).to.equal(10);
241+
expect(wrapper.vm.parsedDot.color).to.equal("white");
242+
expect(wrapper.vm.parsedDot.backgroundColor).to.equal("green");
243+
});
244+
245+
it(`converts the size percent value to pixel correctly`, () => {
246+
const dot = "5%";
247+
const wrapper = localFactory({ progress, size, dot: dotParser(dot) });
248+
const dotPixelSize = calculateThickness(dot);
249+
expect(wrapper.vm.dotSize).to.equal(dotPixelSize);
250+
});
251+
it("applies default value correctly", () => {
252+
const wrapper = factory({ progress }, VueEllipseProgress);
253+
const circleWrapper = wrapper.findComponent(Circle);
254+
const circleContainerWrapper = wrapper.findComponent(CircleContainer);
255+
256+
expect(wrapper.props("dot")).to.equal(0);
257+
expect(circleContainerWrapper.props("dot")).to.equal(0);
258+
expect(circleWrapper.vm.parsedDot.size).to.equal("0");
259+
expect(circleWrapper.vm.parsedDot.color).to.equal("white");
260+
expect(circleWrapper.vm.dotSize).to.equal(0);
261+
});
262+
});
263+
});
226264
});

0 commit comments

Comments
 (0)