/
main.test.mjs
44 lines (39 loc) · 1.13 KB
/
main.test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { describe, expect, test } from "vitest";
import * as main from "../src/main";
describe("repr()", () => {
test("output quotes strings", () => {
const result = main.repr("hello, world");
expect(result).toBe('"hello, world"');
});
});
describe("formatFailureMessage()", () => {
test("prereq-pattern", () => {
expect(
main.formatFailureMessage("Hello, ${prereq-pattern}!", "world", "", "")
).toBe('Hello, "world"!');
});
test("file-pattern", () => {
expect(
main.formatFailureMessage("Hello, ${file-pattern}!", "", "world", "")
).toBe('Hello, "world"!');
});
test("skip-label", () => {
expect(
main.formatFailureMessage("Hello, ${skip-label}!", "", "", "world")
).toBe('Hello, "world"!');
});
test("all arguments", () => {
const given =
"prereq: ${prereq-pattern}, file: ${file-pattern}, label: ${skip-label}";
const want =
'prereq: "prereqPattern", file: "filePattern", label: "skipLabel"';
expect(
main.formatFailureMessage(
given,
"prereqPattern",
"filePattern",
"skipLabel"
)
).toBe(want);
});
});