Skip to content

Commit

Permalink
refactor(test): update test type from PluginInputs to CommandContext
Browse files Browse the repository at this point in the history
Changed type casting in tests from PluginInputs to CommandContext to match updated codebase.
  • Loading branch information
gentlementlegen committed Oct 14, 2024
1 parent ae1f29f commit 51fe242
Showing 1 changed file with 35 additions and 44 deletions.
79 changes: 35 additions & 44 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, it } from "@jest/globals";
import { drop } from "@mswjs/data";
import { run } from "../src/run";
import { PluginInputs } from "../src/types/plugin-input";
import { CommandContext } from "../src/types/plugin-input";
import { db } from "./__mocks__/db";
import { server } from "./__mocks__/node";
import commentCreatedPayload from "./__mocks__/payloads/comment-created.json";
Expand Down Expand Up @@ -64,63 +64,54 @@ describe("User tests", () => {
it("Should run the command", async () => {
expect(
async () =>
await run(
{
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: commentCreatedPayload,
} as PluginInputs,
{ SUPABASE_URL: "", SUPABASE_KEY: "" }
)
await run({
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: commentCreatedPayload,
} as unknown as CommandContext)
).not.toThrow();
});

it("Should ignore invalid command", async () => {
expect(
async () =>
await run(
{
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: {
...commentCreatedPayload,
comment: {
...commentCreatedPayload.comment,
body: "/foobar @ubiquibot",
},
await run({
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: {
...commentCreatedPayload,
comment: {
...commentCreatedPayload.comment,
body: "/foobar @ubiquibot",
},
} as PluginInputs,
{ SUPABASE_URL: "", SUPABASE_KEY: "" }
)
},
} as unknown as CommandContext)
).not.toThrow();
});

it("Should not throw on invalid arguments", async () => {
expect(
async () =>
await run(
{
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: {
...commentCreatedPayload,
comment: {
...commentCreatedPayload.comment,
body: "/query ubiquibot",
},
await run({
eventName: event,
ref: "",
authToken: "",
stateId: "",
settings: { allowPublicQuery: true },
eventPayload: {
...commentCreatedPayload,
comment: {
...commentCreatedPayload.comment,
body: "/query ubiquibot",
},
} as PluginInputs,
{ SUPABASE_URL: "", SUPABASE_KEY: "" }
)
},
} as unknown as CommandContext)
).not.toThrow();
});
});

0 comments on commit 51fe242

Please sign in to comment.