getAssetFromKV-optional.js 952 B

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