refactor: migrate legacy wire namespace to wrn
This commit is contained in:
@@ -3,7 +3,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import {
|
||||
compileWireArtifacts,
|
||||
compileWrnArtifacts,
|
||||
setCompileCacheDir,
|
||||
setCompileImportOptions,
|
||||
} from "../src/pipeline.ts";
|
||||
@@ -31,24 +31,24 @@ function fixture(): { root: string; page: string } {
|
||||
test("legacy, compatible, and explicit import modes are enforced from app config", () => {
|
||||
const { root, page } = fixture();
|
||||
setCompileImportOptions(root, { mode: "legacy" });
|
||||
expect(() => compileWireArtifacts(page, 1)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 1)).not.toThrow();
|
||||
|
||||
const warnings: string[] = [];
|
||||
const originalWarn = console.warn;
|
||||
console.warn = (...args) => warnings.push(args.join(" "));
|
||||
try {
|
||||
setCompileImportOptions(root, { mode: "compatible" });
|
||||
expect(() => compileWireArtifacts(page, 2)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 2)).not.toThrow();
|
||||
expect(warnings.some((message) => message.includes("WRN-IMPORT-IMPLICIT"))).toBe(true);
|
||||
|
||||
setCompileImportOptions(root, { mode: "explicit" });
|
||||
expect(() => compileWireArtifacts(page, 3)).toThrow("WRN-IMPORT-IMPLICIT");
|
||||
expect(() => compileWrnArtifacts(page, 3)).toThrow("WRN-IMPORT-IMPLICIT");
|
||||
|
||||
writeFileSync(
|
||||
page,
|
||||
'import Card from "@/components/Card.wrn"\npage Home { view { <Card /> } }',
|
||||
);
|
||||
expect(() => compileWireArtifacts(page, 4)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 4)).not.toThrow();
|
||||
} finally {
|
||||
console.warn = originalWarn;
|
||||
}
|
||||
@@ -68,5 +68,5 @@ test("compiler-native reactive elements do not require application imports", ()
|
||||
}`,
|
||||
);
|
||||
setCompileImportOptions(root, { mode: "explicit" });
|
||||
expect(() => compileWireArtifacts(page, 5)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 5)).not.toThrow();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user