Skip to content

Commit

Permalink
test: add a case about duplicate handler registration
Browse files Browse the repository at this point in the history
  • Loading branch information
sor4chi committed Nov 30, 2023
1 parent 47d525f commit 8836991
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/hono-do/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join } from "path";
import { unstable_dev } from "wrangler";

import { generateHonoObject } from "../src";
import { Errors } from "../src/error";

import type { UnstableDevWorker } from "wrangler";

Expand Down Expand Up @@ -52,6 +53,17 @@ describe("generateHonoObject", () => {
.webSocketClose(async () => {})
.webSocketError(async () => {});
});

it("should error when multiple handler set to same Hono Object", async () => {
const DO = generateHonoObject("/", () => {});
DO.webSocketMessage(async () => {});
expect(() => DO.alarm(async () => {})).not.toThrowError(
Errors.handlerAlreadySet("alarm"),
);
expect(() => DO.webSocketMessage(async () => {})).toThrowError(
Errors.handlerAlreadySet("webSocketMessage"),
);
});
});

describe("Worker", () => {
Expand Down

0 comments on commit 8836991

Please sign in to comment.