| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import { expect, test } from "bun:test"
- import { createRoot, createSignal } from "solid-js"
- import type { InboxItem } from "@/pages/paas/inbox"
- import { createInboxOpenState } from "@/pages/paas/inbox-panel-state"
- // Bun cannot compile Solid JSX here and the unit suite resolves the server Solid build,
- // where effects are inert, so the panel state is covered by the browser-condition suite.
- const item: InboxItem = {
- id: "unread:run_1",
- kind: "unread",
- title: "研究计划",
- detail: "科研助手",
- projectID: "project_1",
- projectName: "测试项目",
- chatID: "chat_1",
- runID: "run_1",
- at: 1,
- }
- test("an emptied inbox list resets open so a recreated panel stays closed", () => {
- const [items, setItems] = createSignal([item])
- const mounted = createRoot((dispose) => ({
- panel: createInboxOpenState(items),
- dispose,
- }))
- expect(mounted.panel.open()).toBe(false)
- mounted.panel.setOpen(true)
- expect(mounted.panel.open()).toBe(true)
- setItems([])
- expect(mounted.panel.open()).toBe(false)
- setItems([item])
- expect(mounted.panel.open()).toBe(false)
- mounted.dispose()
- })
|