Skip to content

Commit

Permalink
feat: add tests for defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Jun 5, 2024
1 parent 95b1bcb commit b7bd2f9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,46 @@ describe("Worker tests", () => {
} as unknown as GitHubContext);
expect(cfg).toBeTruthy();
});
it("Should fill the config with defaults", async () => {
const cfg = await getConfig({
key: issueOpened,
name: issueOpened,
id: "",
payload: {
repository: {
owner: { login: "ubiquity" },
name: "ubiquibot-kernel",
},
} as unknown as GitHubContext<"issues.closed">["payload"],
octokit: {
rest: {
repos: {
getContent() {
return {
data: `
plugins:
issue_comment.created:
- name: "Run on commment created"
uses:
- id: plugin-A
plugin: https://plugin-a.internal
`,
};
},
},
},
},
eventHandler: {} as GitHubEventHandler,
} as unknown as GitHubContext);
expect(cfg).toBeTruthy();
const pluginChain = cfg.plugins["issue_comment.created"];
expect(pluginChain.length).toBe(1);
expect(pluginChain[0].uses.length).toBe(1);
expect(pluginChain[0].skipBotEvents).toBeTrue();
expect(pluginChain[0].uses[0].id).toBe("plugin-A");
expect(pluginChain[0].uses[0].plugin).toBe("https://plugin-a.internal");
expect(pluginChain[0].uses[0].with).toEqual({});
});
it("Should merge the configuration when found", async () => {
const cfg = await getConfig({
key: issueOpened,
Expand Down

0 comments on commit b7bd2f9

Please sign in to comment.