-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.test.ts
More file actions
37 lines (33 loc) · 1.18 KB
/
Copy pathapp.test.ts
File metadata and controls
37 lines (33 loc) · 1.18 KB
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
28
29
30
31
32
33
34
35
36
37
import { describe, expect, test } from "bun:test";
import { existsSync, mkdtempSync, rmSync } from "fs";
import { tmpdir } from "os";
import path from "path";
import index from "../index.html";
import { createApp } from "./app";
function tempGraphPath(): string {
return path.join(mkdtempSync(path.join(tmpdir(), "link-app-")), "graph");
}
function cleanup(graphPath: string): void {
rmSync(path.dirname(graphPath), { recursive: true, force: true });
}
describe("createApp", () => {
test("does not create graph directories during normal startup", () => {
const graphPath = tempGraphPath();
try {
createApp({ index, config: { port: 0, graphPath } });
expect(existsSync(graphPath)).toBe(false);
} finally {
cleanup(graphPath);
}
});
test("passes explicit seed startup through to repository creation", () => {
const graphPath = tempGraphPath();
try {
createApp({ index, config: { port: 0, graphPath }, seed: true });
expect(existsSync(path.join(graphPath, "node-types", "person.json"))).toBe(true);
expect(existsSync(path.join(graphPath, "edge-types", "works-on.json"))).toBe(true);
} finally {
cleanup(graphPath);
}
});
});