-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathsmoke.test.js
More file actions
27 lines (22 loc) · 980 Bytes
/
smoke.test.js
File metadata and controls
27 lines (22 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
const root = import.meta.dir;
const read = (path) => readFileSync(join(root, path), "utf8");
describe("Next.js example shell", () => {
test("initializes the chat API before enabling the client", () => {
const page = read("app/page.tsx");
expect(page).toContain('"use client"');
expect(page).toContain('fetch("/api/chat"');
expect(page).toContain('JSON.stringify({ action: "init" })');
expect(page).toContain("setIsInitialized(true)");
expect(page).toContain('id="status-text"');
});
test("handles streaming data chunks from the chat route", () => {
const page = read("app/page.tsx");
expect(page).toContain("response.body?.getReader()");
expect(page).toContain('line.startsWith("data: ")');
expect(page).toContain("JSON.parse(line.slice(6))");
expect(page).toContain("assistantMessageId");
});
});