|
1 | 1 | import { expect } from "chai";
|
2 |
| -import { shallowMount, mount } from "@vue/test-utils"; |
| 2 | +import { mount } from "@vue/test-utils"; |
3 | 3 | import VueEllipseProgress from "@/components/VueEllipseProgress.vue";
|
4 | 4 | import CircleContainer from "@/components/Circle/CircleContainer.vue";
|
5 | 5 | import Counter from "@/components/Counter.vue";
|
6 |
| -import { dotParser } from "@/components/optionsParser"; |
| 6 | +import { animationParser, dotParser } from "@/components/optionsParser"; |
| 7 | +import props from "@/components/interface"; |
7 | 8 |
|
8 | 9 | const factory = (propsData, slots = {}) => {
|
9 | 10 | return mount(VueEllipseProgress, {
|
@@ -265,5 +266,46 @@ describe("[ EllipseProgressContainer.vue ]", () => {
|
265 | 266 | expect(width).to.equal(dot.width);
|
266 | 267 | });
|
267 | 268 | });
|
| 269 | + describe("#animation parser", () => { |
| 270 | + it("applies default #animation value", () => { |
| 271 | + const defaultAnimation = { |
| 272 | + type: "default", |
| 273 | + duration: 1000, |
| 274 | + delay: 400, |
| 275 | + }; |
| 276 | + const parsedAnimation = animationParser(props.animation.default); |
| 277 | + for (const prop in defaultAnimation) { |
| 278 | + expect(parsedAnimation[prop]).to.equal(defaultAnimation[prop]); |
| 279 | + } |
| 280 | + }); |
| 281 | + it("parses #animation correctly", () => { |
| 282 | + const { type, duration, delay } = animationParser("rs 500 300"); |
| 283 | + expect(type).to.equal("rs"); |
| 284 | + expect(duration).to.equal(500); |
| 285 | + expect(delay).to.equal(300); |
| 286 | + }); |
| 287 | + it("parses #animation correctly with default duration", () => { |
| 288 | + const { type, duration } = animationParser("bounce"); |
| 289 | + expect(type).to.equal("bounce"); |
| 290 | + expect(duration).to.equal(animationParser(props.animation.default).duration); |
| 291 | + }); |
| 292 | + it("parses #animation correctly with default delay", () => { |
| 293 | + const { type, duration, delay } = animationParser("bounce 2000"); |
| 294 | + expect(type).to.equal("bounce"); |
| 295 | + expect(duration).to.equal(2000); |
| 296 | + expect(delay).to.equal(animationParser(props.animation.default).delay); |
| 297 | + }); |
| 298 | + it("parses #animation incorrectly with wrong arguments order", () => { |
| 299 | + const { type, duration, delay } = animationParser("300 rs 2000"); |
| 300 | + expect(type).to.not.equal("rs"); |
| 301 | + expect(duration).to.not.equal(300); |
| 302 | + expect(delay).to.equal(2000); |
| 303 | + }); |
| 304 | + it("applies default values for duration and delay if invalid values provided", () => { |
| 305 | + const { duration, delay } = animationParser("loop 20%0 sdf"); |
| 306 | + expect(duration).to.not.equal(animationParser(props.animation.default).duration); |
| 307 | + expect(delay).to.equal(animationParser(props.animation.default).delay); |
| 308 | + }); |
| 309 | + }); |
268 | 310 | });
|
269 | 311 | });
|
0 commit comments