Skip to content

Commit 9d83db0

Browse files
committed
test: pass animation tests animation prop properly
1 parent fbdaa97 commit 9d83db0

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/components/optionsParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const lineModeParser = (options) => {
99
};
1010
};
1111

12-
const animationParser = (animation) => {
12+
export const animationParser = (animation) => {
1313
const animationConfig = animation.trim().split(" ");
1414
return {
1515
type: animationConfig[0],

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { expect } from "chai";
2-
import Vue from "vue";
32
import Circle from "@/components/Circle/Circle.vue";
43
import HalfCircle from "@/components/Circle/HalfCircle.vue";
54
import CircleContainer from "@/components/Circle/CircleContainer.vue";
65
import CircleDot from "@/components/Circle/CircleDot.vue";
76
import { factory } from "@/../tests/helper";
7+
import { animationParser } from "@/components/optionsParser";
88

99
const localFactory = (props, container = Circle) => {
1010
return factory({ container, props });
@@ -32,23 +32,19 @@ const animationTypeTests = (container, circleClass, prefix = "circle |") => {
3232
}, 250);
3333
});
3434
it(`${prefix} applies @bounce animation class correctly`, async () => {
35-
await wrapper.setProps({ options: { ...wrapper.props().options, animation: "bounce 500 500" } });
36-
await Vue.nextTick();
35+
await wrapper.setProps({ options: { ...wrapper.props().options, animation: animationParser("bounce 500 500") } });
3736
expect(circleProgressWrapper.classes()).to.include("animation__bounce");
3837
});
3938
it(`${prefix} applies @loop animation class correctly`, async () => {
40-
await wrapper.setProps({ options: { ...wrapper.props().options, animation: "loop 500 500" } });
41-
await Vue.nextTick();
39+
await wrapper.setProps({ options: { ...wrapper.props().options, animation: animationParser("loop 500 500") } });
4240
expect(circleProgressWrapper.classes()).to.include("animation__loop");
4341
});
4442
it(`${prefix} applies @reverse animation class correctly`, async () => {
45-
await wrapper.setProps({ options: { ...wrapper.props().options, animation: "reverse 500 500" } });
46-
await Vue.nextTick();
43+
await wrapper.setProps({ options: { ...wrapper.props().options, animation: animationParser("reverse 500 500") } });
4744
expect(circleProgressWrapper.classes()).to.include("animation__reverse");
4845
});
4946
it(`${prefix} applies @rs animation class correctly`, async () => {
50-
await wrapper.setProps({ options: { ...wrapper.props().options, animation: "rs 500 500" } });
51-
await Vue.nextTick();
47+
await wrapper.setProps({ options: { ...wrapper.props().options, animation: animationParser("rs 500 500") } });
5248
expect(circleProgressWrapper.classes()).to.include("animation__rs");
5349
});
5450
};
@@ -60,13 +56,13 @@ const animationDurationTests = (container, circleClass, prefix = "circle | ") =>
6056
expect(circleProgressWrapper.element.style.animationDuration).to.equal("1000ms");
6157
});
6258
it(`${prefix} applies provided duration value as transition and animation duration`, () => {
63-
const circleProgressWrapper = localFactory({ animation: "rs 500" }, container).find(circleClass);
59+
const circleProgressWrapper = localFactory({ animation: animationParser("rs 500") }, container).find(circleClass);
6460

6561
expect(circleProgressWrapper.element.style.transition).to.include("500ms");
6662
expect(circleProgressWrapper.element.style.animationDuration).to.equal("500ms");
6763
});
6864
it(`${prefix} applies @0 duration value as transition and animation duration`, () => {
69-
const circleProgressWrapper = localFactory({ animation: "rs 0" }, container).find(circleClass);
65+
const circleProgressWrapper = localFactory({ animation: animationParser("rs 0") }, container).find(circleClass);
7066

7167
expect(circleProgressWrapper.element.style.transition).to.include("0ms");
7268
expect(circleProgressWrapper.element.style.animationDuration).to.equal("0ms");
@@ -77,7 +73,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
7773
expect(localFactory({}, container).vm.parsedAnimation.delay).to.equal(400);
7874
});
7975
it(`${prefix} applies @0 delay value as animation-delay`, () => {
80-
expect(localFactory({ animation: "rs 0 0" }, container).vm.parsedAnimation.delay).to.equal(0);
76+
expect(localFactory({ animation: animationParser("rs 0 0") }, container).vm.parsedAnimation.delay).to.equal(0);
8177
});
8278

8379
const progress = 60;
@@ -93,7 +89,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
9389

9490
it(`${prefix} don not applies progress before delay`, () => {
9591
const wrapper = localFactory(
96-
{ progress, size, thickness, emptyThickness: thickness, animation: "rs 500 100" },
92+
{ progress, size, thickness, emptyThickness: thickness, animation: animationParser("rs 500 100") },
9793
container
9894
);
9995
const circleProgressWrapper = wrapper.find(circleClass);
@@ -102,7 +98,7 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
10298
});
10399
it(`${prefix} applies the progress after delay`, (done) => {
104100
const wrapper = localFactory(
105-
{ progress, size, thickness, emptyThickness: thickness, animation: "rs 500 100" },
101+
{ progress, size, thickness, emptyThickness: thickness, animation: animationParser("rs 500 100") },
106102
container
107103
);
108104
const circleProgressWrapper = wrapper.find(circleClass);
@@ -115,11 +111,14 @@ const animationDelayTests = (container, circleClass, prefix = "circle | ") => {
115111
};
116112

117113
describe("#animation", () => {
118-
const circleContainerWrapper = localFactory({ progress: 50, dot: 5, animation: "rs 500 5" }, CircleContainer);
114+
const circleContainerWrapper = localFactory(
115+
{ progress: 50, dot: 5, animation: animationParser("rs 500 5") },
116+
CircleContainer
117+
);
119118
const circleDotWrapper = circleContainerWrapper.findComponent(CircleDot);
120119

121120
it("it parses the #animation property correctly", () => {
122-
const wrapper = localFactory({ animation: "rs 2000 200" });
121+
const wrapper = localFactory({ animation: animationParser("rs 2000 200") });
123122

124123
expect(wrapper.vm.parsedAnimation.type).to.equal("rs");
125124
expect(wrapper.vm.parsedAnimation.duration).to.equal(2000);
@@ -161,7 +160,7 @@ describe("#animation", () => {
161160
animationDelayTests(HalfCircle, "path.ep-half-circle--progress", "half circle |");
162161

163162
const progress = 50;
164-
const wrapper = localFactory({ dot: 5, animation: "rs 500 50" }, CircleContainer);
163+
const wrapper = localFactory({ dot: 5, animation: animationParser("rs 500 50") }, CircleContainer);
165164
const cdWrapper = wrapper.findComponent(CircleDot);
166165
const startRotation = wrapper.props("angle") + 90;
167166

0 commit comments

Comments
 (0)