Add proper typing to integration test websocket mocks
Import and apply WsData type to the test server's websocket handlers to ensure mock websocket objects match production typing.
This commit is contained in:
parent
0235b2c3e6
commit
d654a1bcdf
1 changed files with 7 additions and 2 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
||||||
import type { ServerMessage } from "./protocol";
|
import type { ServerMessage } from "./protocol";
|
||||||
import { decode } from "./protocol";
|
import { decode } from "./protocol";
|
||||||
import { getOrCreateSession, getSession, removeSession } from "./session";
|
import {
|
||||||
|
type WsData,
|
||||||
|
getOrCreateSession,
|
||||||
|
getSession,
|
||||||
|
removeSession,
|
||||||
|
} from "./session";
|
||||||
|
|
||||||
describe("WebSocket concurrent edits integration", () => {
|
describe("WebSocket concurrent edits integration", () => {
|
||||||
let server: ReturnType<typeof Bun.serve>;
|
let server: ReturnType<typeof Bun.serve>;
|
||||||
|
|
@ -9,7 +14,7 @@ describe("WebSocket concurrent edits integration", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// start server for each test
|
// start server for each test
|
||||||
server = Bun.serve({
|
server = Bun.serve<WsData>({
|
||||||
port: PORT,
|
port: PORT,
|
||||||
fetch(req, server) {
|
fetch(req, server) {
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue