Initial Commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Build-artifact tests. Assume `bunx turbo build --filter=@suaveplan/storage-uri-plugin-bundle`
|
||||
* has already produced `dist/`. The repo's turbo pipeline always builds before test.
|
||||
* If you run these in isolation, run `bun run build` first.
|
||||
*/
|
||||
import { readFileSync, statSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const distDir = fileURLToPath(new URL("../../dist/", import.meta.url));
|
||||
|
||||
describe("storage-uri-plugin-bundle build artifacts", () => {
|
||||
it("build emits a non-empty dist/node-fetch/node-fetch.js", {
|
||||
timeout: 30000,
|
||||
}, () => {
|
||||
const path = `${distDir}node-fetch/node-fetch.js`;
|
||||
const stat = statSync(path);
|
||||
expect(stat.isFile()).toBe(true);
|
||||
expect(stat.size).toBeGreaterThan(0);
|
||||
expect(path.endsWith(".js")).toBe(true);
|
||||
});
|
||||
|
||||
it("dist/index.js contains no node: imports", { timeout: 30000 }, () => {
|
||||
const source = readFileSync(`${distDir}index.js`, "utf8");
|
||||
expect(source).not.toMatch(/from\s+["']node:/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Proves the emitted `dist/node-fetch/node-fetch.js` is actually runnable —
|
||||
* not just present on disk. Dynamic-imports the built artifact and asserts
|
||||
* the `nodeFileFetch` export is a function.
|
||||
*/
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
describe("storage-uri-plugin-bundle ./node-fetch runtime import", () => {
|
||||
it("emitted node-fetch.js exports nodeFileFetch as a function", {
|
||||
timeout: 30000,
|
||||
}, async () => {
|
||||
const url = new URL(
|
||||
"../../dist/node-fetch/node-fetch.js",
|
||||
import.meta.url
|
||||
);
|
||||
const imported = (await import(url.href)) as {
|
||||
nodeFileFetch: unknown;
|
||||
};
|
||||
expect(typeof imported.nodeFileFetch).toBe("function");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user