-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathintegration.test.ts
62 lines (53 loc) · 1.92 KB
/
integration.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
62
import {WriteStreamsMock} from "../../../src/write-streams.js";
import {handler} from "../../../src/handler.js";
import chalk from "chalk";
import {initSpawnSpy} from "../../mocks/utils.mock.js";
import {WhenStatics} from "../../mocks/when-statics.js";
beforeAll(() => {
initSpawnSpy(WhenStatics.all);
});
test("after-script <test-job>", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/after-script",
job: ["test-job"],
}, writeStreams);
const expected = [
chalk`{blueBright test-job} {greenBright >} Cleanup after test`,
];
expect(writeStreams.stdoutLines).toEqual(expect.arrayContaining(expected));
});
test("after-script <build-job> (default)", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/after-script",
job: ["build-job"],
}, writeStreams);
const expected = [
chalk`{blueBright build-job} {greenBright >} Cleanup after test`,
];
expect(writeStreams.stdoutLines).toEqual(expect.arrayContaining(expected));
});
test("after-script <deploy-job>", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/after-script",
job: ["deploy-job"],
}, writeStreams);
const expected = [
chalk`{blueBright deploy-job} {greenBright >} running`,
chalk`{blueBright deploy-job} {greenBright >} success`,
];
expect(writeStreams.stdoutLines).toEqual(expect.arrayContaining(expected));
});
test("after-script <post-job>", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
cwd: "tests/test-cases/after-script",
job: ["post-job"],
}, writeStreams);
const expected = [
chalk`{blueBright post-job} {greenBright >} failed`,
];
expect(writeStreams.stdoutLines).toEqual(expect.arrayContaining(expected));
});