Skip to content

Commit 42a67dc

Browse files
committed
test: improve test mocking.
1 parent f3b5ebf commit 42a67dc

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/api.spec.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,26 @@ const mockOctokit = {
4444

4545
describe("API", () => {
4646
beforeEach(() => {
47-
jest.spyOn(core, "getInput").mockReturnValue("");
47+
jest.spyOn(core, "getInput").mockImplementation((key: string) => {
48+
switch (key) {
49+
case "token":
50+
return "token";
51+
case "ref":
52+
return "ref";
53+
case "repo":
54+
return "repo";
55+
case "owner":
56+
return "owner";
57+
case "workflow":
58+
return "workflow";
59+
case "workflow_inputs":
60+
return JSON.stringify({ testInput: "test" });
61+
case "workflow_timeout_seconds":
62+
return "30";
63+
default:
64+
return "";
65+
}
66+
});
4867
jest.spyOn(github, "getOctokit").mockReturnValue(mockOctokit as any);
4968
init();
5069
});
@@ -172,7 +191,7 @@ describe("API", () => {
172191
repo: "repository",
173192
owner: "owner",
174193
workflow: "workflow_name",
175-
workflowInputs: {},
194+
workflowInputs: { testInput: "test" },
176195
workflowTimeoutSeconds: 60,
177196
};
178197

0 commit comments

Comments
 (0)