socket expects undefined instead of null

This commit is contained in:
Peter Clement 2024-12-30 12:16:02 +00:00
parent a94adced72
commit c30c68c289
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import { get } from "svelte/store" import { get } from "svelte/store"
import { createBuilderWebsocket } from "./websocket.js" import { createBuilderWebsocket } from "./websocket.js"
import { Socket } from "socket.io-client"
import { BuilderSocketEvent } from "@budibase/shared-core" import { BuilderSocketEvent } from "@budibase/shared-core"
import { BudiStore } from "../BudiStore.js" import { BudiStore } from "../BudiStore.js"
import { TOUR_KEYS } from "components/portal/onboarding/tours.js" import { TOUR_KEYS } from "components/portal/onboarding/tours.js"
@ -18,7 +19,7 @@ interface BuilderState {
tourKey: string | null tourKey: string | null
tourStepKey: string | null tourStepKey: string | null
hoveredComponentId: string | null hoveredComponentId: string | null
websocket?: ReturnType<typeof createBuilderWebsocket> websocket?: Socket
} }
export const INITIAL_BUILDER_STATE: BuilderState = { export const INITIAL_BUILDER_STATE: BuilderState = {
@ -34,7 +35,7 @@ export const INITIAL_BUILDER_STATE: BuilderState = {
} }
export class BuilderStore extends BudiStore<BuilderState> { export class BuilderStore extends BudiStore<BuilderState> {
websocket?: ReturnType<typeof createBuilderWebsocket> websocket?: Socket
constructor() { constructor() {
super({ ...INITIAL_BUILDER_STATE }) super({ ...INITIAL_BUILDER_STATE })

View File

@ -65,7 +65,7 @@ describe("Builder store", () => {
ctx.test.builderStore.reset() ctx.test.builderStore.reset()
expect(disconnected).toBe(true) expect(disconnected).toBe(true)
expect(ctx.test.store).toStrictEqual(INITIAL_BUILDER_STATE) expect(ctx.test.store).toStrictEqual(INITIAL_BUILDER_STATE)
expect(ctx.test.builderStore.websocket).toBeNull() expect(ctx.test.builderStore.websocket).toBeUndefined()
}) })
it("Attempt to emit a resource select event to the websocket on select", ctx => { it("Attempt to emit a resource select event to the websocket on select", ctx => {