Skip to content

Commit a7e13a0

Browse files
committed
Mock websocket on storybook to support OneWayWebsocket
1 parent 38a8d62 commit a7e13a0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

site/src/testHelpers/storybook.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export const withWebSocket = (Story: FC, { parameters }: StoryContext) => {
7575
let callEventsDelay: number;
7676

7777
window.WebSocket = class WebSocket {
78+
public readyState = 1;
79+
7880
addEventListener(type: string, callback: CallbackFn) {
7981
listeners.set(type, callback);
8082

@@ -93,6 +95,8 @@ export const withWebSocket = (Story: FC, { parameters }: StoryContext) => {
9395
}, 0);
9496
}
9597

98+
removeEventListener(type: string, callback: CallbackFn) {}
99+
96100
close() {}
97101
} as unknown as typeof window.WebSocket;
98102

0 commit comments

Comments
 (0)