Skip to content

Commit 01d2913

Browse files
committed
test: add dash parser tests
1 parent 3a49c4f commit 01d2913

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/components/optionsParser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const animationParser = (animation) => {
1818
};
1919
};
2020

21-
const dashParser = (dash) => {
21+
export const dashParser = (dash) => {
2222
const dashConfig = dash.trim().split(" ");
2323
const isStrict = dashConfig[0] === "strict";
2424
if (!isStrict) {

tests/unit/container.spec.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mount } from "@vue/test-utils";
33
import VueEllipseProgress from "@/components/VueEllipseProgress.vue";
44
import CircleContainer from "@/components/Circle/CircleContainer.vue";
55
import Counter from "@/components/Counter.vue";
6-
import { animationParser, dotParser } from "@/components/optionsParser";
6+
import { animationParser, dotParser, dashParser } from "@/components/optionsParser";
77
import props from "@/components/interface";
88

99
const factory = (propsData, slots = {}) => {
@@ -307,5 +307,20 @@ describe("[ EllipseProgressContainer.vue ]", () => {
307307
expect(delay).to.equal(animationParser(props.animation.default).delay);
308308
});
309309
});
310+
describe("#dash parser", () => {
311+
it("returns the value as without strict mode", () => {
312+
const dash = "10 20";
313+
expect(dashParser(dash)).to.equal(dash);
314+
});
315+
it("parses the value correctly is strict mode", () => {
316+
const dash = "strict 50 0.5";
317+
const { count, spacing } = dashParser(dash);
318+
expect(count).to.equal(50);
319+
expect(spacing).to.equal(0.5);
320+
});
321+
it("parses default value correctly", () => {
322+
expect(dashParser(props.dash.default)).to.equal("");
323+
});
324+
});
310325
});
311326
});

0 commit comments

Comments
 (0)