Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript): compile-time invalid argument errors #465

Merged
merged 4 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions test/integration/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ describe("server-test", () => {
});
});

test("initialised without options", (t) => {
try {
// @ts-expect-error
new Webhooks();
t.fail("should throw error");
} catch (error) {
t();
}
test("initialised without options", () => {
// @ts-expect-error
expect(() => new Webhooks()).toThrow();
});

test("GET /", (t) => {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/sign-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ test("sign(secret) without eventPayload throws", () => {

test("sign({secret, algorithm}) with invalid algorithm throws", () => {
expect(() =>
sign.bind(null, { secret, algorithm: "sha2" as "sha1" }, eventPayload)()
// @ts-expect-error
sign.bind(null, { secret, algorithm: "sha2" }, eventPayload)()
).toThrow();
});

Expand Down
12 changes: 5 additions & 7 deletions test/unit/event-handler-on-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { receiverOn } from "../../src/event-handler/on";
import { EmitterWebhookEventName, State } from "../../src/types";
import { State } from "../../src/types";

function noop() {}

Expand All @@ -24,17 +24,15 @@ test("receiver.on with invalid event name", () => {
});

test("receiver.on with event name of '*' throws an error", () => {
expect(() =>
receiverOn(state, "*" as EmitterWebhookEventName, noop)
).toThrowError(
// @ts-expect-error
expect(() => receiverOn(state, "*", noop)).toThrowError(
jablko marked this conversation as resolved.
Show resolved Hide resolved
'Using the "*" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onAny() method instead'
);
});

test("receiver.on with event name of 'error' throws an error", () => {
expect(() =>
receiverOn(state, "error" as EmitterWebhookEventName, noop)
).toThrowError(
// @ts-expect-error
expect(() => receiverOn(state, "error", noop)).toThrowError(
jablko marked this conversation as resolved.
Show resolved Hide resolved
'Using the "error" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onError() method instead'
);
});