| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import fs from "node:fs/promises"; |
| 4 | import path from "node:path"; |
| 5 | import { fileURLToPath } from "node:url"; |
| 6 | |
| 7 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 8 | |
| 9 | test("ThreadStore is initialized before bridge startup opens it", async () => { |
| 10 | const source = await fs.readFile(path.join(__dirname, "../src/index.mjs"), "utf8"); |
| 11 | const declaration = source.indexOf("class ThreadStore"); |
| 12 | const startupUse = source.indexOf("await ThreadStore.open"); |
| 13 | const wsStart = source.indexOf("wsClient.start"); |
| 14 | const reattachCall = source.indexOf("reattachActiveTurns().catch"); |
| 15 | |
| 16 | assert.notEqual(declaration, -1); |
| 17 | assert.notEqual(startupUse, -1); |
| 18 | assert.notEqual(wsStart, -1); |
| 19 | assert.notEqual(reattachCall, -1); |
| 20 | assert.ok(declaration < startupUse); |
| 21 | assert.ok(wsStart < reattachCall); |
| 22 | }); |
| 23 |