summaryrefslogtreecommitdiff
path: root/node_modules/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV-optional.js
blob: 83838ad3c46813577f769ddec4b054a9dcaf63eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = require("ava");
const mocks_1 = require("../mocks");
(0, mocks_1.mockGlobalScope)();
// manually reset manifest global, to test optional behaviour
Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined });
const index_1 = require("../index");
(0, ava_1.default)('getAssetFromKV return correct val from KV without manifest', async (t) => {
    (0, mocks_1.mockRequestScope)();
    // manually reset manifest global, to test optional behaviour
    Object.assign(global, { __STATIC_CONTENT_MANIFEST: undefined });
    const event = (0, mocks_1.getEvent)(new Request('https://blah.com/key1.123HASHBROWN.txt'));
    const res = await (0, index_1.getAssetFromKV)(event);
    if (res) {
        t.is(await res.text(), 'val1');
        t.true(res.headers.get('content-type').includes('text'));
    }
    else {
        t.fail('Response was undefined');
    }
});