mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks. - Preserve compiler import boundaries and protected fixtures while cleaning up lint findings. - Standardize source formatting and validate import, fixture, and embedded-source protections.
26 lines
814 B
TypeScript
26 lines
814 B
TypeScript
import { expect, test } from "vitest";
|
|
import { runCompilerTask } from "./task.js";
|
|
|
|
test("compiler work starts after the caller can suspend and preserves its result", async () => {
|
|
const events: string[] = [];
|
|
const result = { ok: true, diagnostics: [] };
|
|
const pending = runCompilerTask(() => {
|
|
events.push("compile");
|
|
return result;
|
|
});
|
|
events.push("caller");
|
|
expect(events).toEqual(["caller"]);
|
|
expect(await pending).toBe(result);
|
|
expect(events).toEqual(["caller", "compile"]);
|
|
});
|
|
|
|
test("synchronous compiler failures reject the task without escaping its microtask", async () => {
|
|
const failure = new Error("compiler failed");
|
|
await expect(
|
|
runCompilerTask(() => {
|
|
throw failure;
|
|
}),
|
|
).rejects.toBe(failure);
|
|
expect(await runCompilerTask(() => 42)).toBe(42);
|
|
});
|