-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
get-show-schedules-test.js
68 lines (57 loc) · 1.55 KB
/
get-show-schedules-test.js
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
63
64
65
66
67
68
import { readFile } from "fs/promises";
import { dirname, join, basename } from "path";
import { fileURLToPath } from "url";
import { deepEqual } from "assert/strict";
import { test } from "uvu";
import MockDate from "mockdate";
import { run } from "../get-schow-schedules.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("get-schow-schedules.js", async () => {
// mock date
MockDate.set("2021-08-20");
// mock environment variables
const mockEnv = {};
// mock octokit
const mockOctokit = {
async paginate(route, parameters) {
if (route === "GET /repos/{owner}/{repo}/issues") {
deepEqual(parameters, {
owner: "gr2m",
repo: "helpdesk",
labels: "show",
state: "open",
per_page: 100,
});
return JSON.parse(
await readFile(
join(__dirname, "fixtures/open-show-issues.json"),
"utf8"
)
);
}
throw new Error("Unexpected route: " + route);
},
};
// mock core
const outputLogs = [];
const outputs = {};
const mockCore = {
info(message) {
outputLogs.push(message);
},
setOutput(name, value) {
outputs[name] = value;
},
};
// run action
await run(mockEnv, mockOctokit, mockCore);
// assertions
deepEqual(outputLogs, [
"CRON schedule for upcoming shows is: [ { start: '57 16 26 8 *', announcement: '27 16 26 8 *' } ]",
]);
deepEqual(outputs, {
schedule_announcement: "27 16 26 8 *",
schedule_start: "57 16 26 8 *",
});
});
test.run();