-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathoutro.test.ts
61 lines (50 loc) · 1.24 KB
/
outro.test.ts
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import chalk from "chalk";
import { SpyInstance, beforeEach, describe, expect, it, vi } from "vitest";
import { outro } from "./outro.js";
const mockOutro = vi.fn();
vi.mock("@clack/prompts", () => ({
get outro() {
return mockOutro;
},
}));
let mockConsoleLog: SpyInstance;
describe("outro", () => {
beforeEach(() => {
mockConsoleLog = vi
.spyOn(console, "log")
.mockImplementation(() => undefined);
});
it("logs only basic statements when no lines are provided", () => {
outro([{ label: "Abc 123" }]);
expect(mockConsoleLog.mock.calls).toEqual([
[chalk.blue("Abc 123")],
[],
[chalk.greenBright(`See ya! 👋`)],
[],
]);
});
it("also logs lines when provided", () => {
outro([{ label: "Abc 123", lines: ["one", "two"] }]);
expect(mockConsoleLog.mock.calls).toEqual([
[chalk.blue("Abc 123")],
[],
["one"],
["two"],
[],
[chalk.greenBright(`See ya! 👋`)],
[],
]);
});
it("logs lines as code when variant is specified", () => {
outro([{ label: "Abc 123", lines: ["one", "two"], variant: "code" }]);
expect(mockConsoleLog.mock.calls).toEqual([
[chalk.blue("Abc 123")],
[],
[chalk.gray("one")],
[chalk.gray("two")],
[],
[chalk.greenBright(`See ya! 👋`)],
[],
]);
});
});