-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.ts
38 lines (36 loc) · 1004 Bytes
/
index.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
import { run } from "./index";
import { initProgram } from "./utils/options";
import { vi, describe, it, expect } from "vitest";
vi.mock("./utils/options", () => ({
initProgram: vi.fn(() => ({
owner: "@getyourguide",
repo: "test-repo",
commit: "12345678910",
baseBranch: ["main"],
branch: "main",
})),
}));
vi.mock("path", () => ({
join: vi.fn(() => "./path-to-coverage.json"),
}));
vi.mock("fs", () => ({
existsSync: vi.fn(() => true),
readFileSync: vi.fn(() => '{"results": "test"}'),
}));
vi.mock("./utils/github-utils");
vi.mock("./utils/datadot-api", () => ({
sendCoverageMetrics: vi.fn().mockResolvedValue(""),
}));
vi.spyOn(console, "info").mockImplementation(() => "");
describe("run program", () => {
it("should upload if we are in a base branch", async () => {
const options = {
...initProgram(),
branch: "main",
};
//@ts-ignore
initProgram.mockReturnValueOnce(options);
await run();
expect(true).toEqual(true);
});
});