mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
refactor: replace Discord Gateway DO with Interaction Endpoint
This commit is contained in:
parent
9bb9cb1444
commit
d540d465d1
27 changed files with 834 additions and 964 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
||||
import { sendMessage } from "../discord-rest";
|
||||
import { dispatchEvent, isGatewayEnabled } from "../discord";
|
||||
import { dispatchEvent } from "../discord";
|
||||
import type { Env, Route } from "../types";
|
||||
|
||||
function mockFetch(handler: (url: string, init?: RequestInit) => Response): void {
|
||||
|
|
@ -12,7 +12,6 @@ function createEnv(overrides: Partial<Env> = {}): Env {
|
|||
return {
|
||||
GITHUB_WEBHOOK_SECRET: "secret",
|
||||
KV: {} as KVNamespace,
|
||||
DISCORD_GATEWAY: {} as DurableObjectNamespace,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
|
@ -68,14 +67,6 @@ describe("discord-rest sendMessage", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isGatewayEnabled", () => {
|
||||
it("is enabled only when set to true", () => {
|
||||
expect(isGatewayEnabled(createEnv({ DISCORD_GATEWAY_ENABLED: "true" }))).toBe(true);
|
||||
expect(isGatewayEnabled(createEnv({ DISCORD_GATEWAY_ENABLED: "false" }))).toBe(false);
|
||||
expect(isGatewayEnabled(createEnv())).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dispatchEvent fallback routing", () => {
|
||||
function createMockKV(): KVNamespace {
|
||||
const store = new Map<string, string>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue