|
1 | 1 | import { describe, it, expect } from "vitest"; |
2 | | -import { mkdtemp, writeFile, readFile, rm } from "node:fs/promises"; |
| 2 | +import { mkdtemp, readFile, rm } from "node:fs/promises"; |
3 | 3 | import { join } from "node:path"; |
4 | 4 | import { tmpdir } from "node:os"; |
5 | 5 |
|
6 | 6 | describe("copy-oauth-success script", () => { |
7 | | - it("exports copyOAuthSuccessHtml() for reuse/testing", async () => { |
8 | | - const mod = await import("../scripts/copy-oauth-success.js"); |
9 | | - expect(typeof mod.copyOAuthSuccessHtml).toBe("function"); |
10 | | - }); |
| 7 | + it("exports copyOAuthSuccessHtml() for reuse/testing", async () => { |
| 8 | + const mod = await import("../scripts/copy-oauth-success.js"); |
| 9 | + expect(typeof mod.copyOAuthSuccessHtml).toBe("function"); |
| 10 | + }); |
11 | 11 |
|
12 | | - it("copies oauth-success.html to the requested destination", async () => { |
13 | | - const mod = await import("../scripts/copy-oauth-success.js"); |
| 12 | + it("copies oauth-success.html to the requested destination", async () => { |
| 13 | + const mod = await import("../scripts/copy-oauth-success.js"); |
14 | 14 |
|
15 | | - const root = await mkdtemp(join(tmpdir(), "opencode-oauth-success-")); |
16 | | - const src = join(root, "oauth-success.html"); |
17 | | - const dest = join(root, "dist", "lib", "oauth-success.html"); |
| 15 | + const root = await mkdtemp(join(tmpdir(), "opencode-oauth-success-")); |
| 16 | + const dest = join(root, "dist", "lib", "oauth-success.html"); |
18 | 17 |
|
19 | | - try { |
20 | | - const html = "<!doctype html><html><body>ok</body></html>"; |
21 | | - await writeFile(src, html, "utf-8"); |
| 18 | + try { |
| 19 | + const html = "<!doctype html><html><body>ok</body></html>"; |
22 | 20 |
|
23 | | - await mod.copyOAuthSuccessHtml({ src, dest }); |
| 21 | + await mod.copyOAuthSuccessHtml({ html, dest }); |
24 | 22 |
|
25 | | - const copied = await readFile(dest, "utf-8"); |
26 | | - expect(copied).toBe(html); |
27 | | - } finally { |
28 | | - await rm(root, { recursive: true, force: true }); |
29 | | - } |
30 | | - }); |
| 23 | + const copied = await readFile(dest, "utf-8"); |
| 24 | + expect(copied).toBe(html); |
| 25 | + } finally { |
| 26 | + await rm(root, { recursive: true, force: true }); |
| 27 | + } |
| 28 | + }); |
31 | 29 | }); |
0 commit comments