Files
wehub-resource-sync 70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:11 +08:00

71 lines
2.1 KiB
TypeScript

import { test } from "vitest";
import {
getJsonResponse,
getTextResponse,
page,
viteTestUrl,
} from "../../__test-utils__";
test("supports Data modules with a '.bin' extension", async ({ expect }) => {
const result = await getJsonResponse("/bin");
expect(result).toEqual({ byteLength: 342936 });
});
test("supports Text modules with a '.html' extension", async ({ expect }) => {
await page.goto(`${viteTestUrl}/html`);
const content = await page.textContent("h1");
expect(content).toBe("Hello world");
});
test("supports Text modules imported via subpath imports", async ({
expect,
}) => {
await page.goto(`${viteTestUrl}/subpath-html`);
const content = await page.textContent("h1");
expect(content).toBe("Hello world");
});
test("supports Text modules imported via subpath imports with extension", async ({
expect,
}) => {
await page.goto(`${viteTestUrl}/subpath-html-with-ext`);
const content = await page.textContent("h1");
expect(content).toBe("Hello world");
});
test("supports Text modules with a '.txt' extension", async ({ expect }) => {
const result = await getTextResponse("/text");
expect(result).toBe("Example text content.\n");
});
test("supports Text modules with a '.sql' extension", async ({ expect }) => {
const result = await getTextResponse("/sql");
expect(result).toBe("SELECT * FROM users;\n");
});
test("supports modules with `__`s in the filename", async ({ expect }) => {
const result = await getTextResponse("/text2");
expect(result).toBe("Example text content 2");
});
test("supports CompiledWasm modules with a '.wasm' extension", async ({
expect,
}) => {
const result = await getJsonResponse("/wasm");
expect(result).toEqual({ result: 7 });
});
test("supports CompiledWasm modules with a '.wasm?module' extension", async ({
expect,
}) => {
const result = await getJsonResponse("/wasm-with-module-param");
expect(result).toEqual({ result: 11 });
});
test("supports CompiledWasm modules with a '.wasm?init' extension", async ({
expect,
}) => {
const result = await getJsonResponse("/wasm-with-init-param");
expect(result).toEqual({ result: 15 });
});