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
23 lines
703 B
TypeScript
23 lines
703 B
TypeScript
import { test, vi } from "vitest";
|
|
import { getAssetFromKV } from "../src/index";
|
|
import { getEvent, mockGlobalScope, mockRequestScope } from "./mocks";
|
|
|
|
test("getAssetFromKV return correct val from KV without manifest", async ({
|
|
expect,
|
|
}) => {
|
|
mockRequestScope();
|
|
mockGlobalScope();
|
|
// manually reset manifest global, to test optional behaviour
|
|
vi.stubGlobal("__STATIC_CONTENT_MANIFEST", undefined);
|
|
|
|
const event = getEvent(new Request("https://blah.com/key1.123HASHBROWN.txt"));
|
|
const res = await getAssetFromKV(event);
|
|
|
|
if (res) {
|
|
expect(await res.text()).toBe("val1");
|
|
expect(res.headers.get("content-type")).toContain("text");
|
|
} else {
|
|
expect.fail("Response was undefined");
|
|
}
|
|
});
|