Skip to content
Myr

utils.test.ts

This file

Path

adapters/cloudflare-workers/src/utils.test.ts

33 lines · 977 bytes · TypeScript

Last changed by

feat(adapters): add the seven adapters as workspace packages (#5463)Yusuke Wadabefore adoptionb877827

History of this file

Take it

feat(adapters): add the seven adapters as workspace packages (#5463)Yusuke Wadabefore adoptionb877827

lines 1–33why, one step back
1import { getContentFromKVAsset } from './utils'
23// Mock4const store: { [key: string]: string } = {5 'index.abcdef.html': 'This is index',6 'assets/static/plain.abcdef.txt': 'Asset text',7}8const manifest = JSON.stringify({9 'index.html': 'index.abcdef.html',10 'assets/static/plain.txt': 'assets/static/plain.abcdef.txt',11})1213Object.assign(global, { __STATIC_CONTENT_MANIFEST: manifest })14Object.assign(global, {15 __STATIC_CONTENT: {16 get: (path: string) => {17 return store[path]18 },19 },20})2122describe('Utils for Cloudflare Workers', () => {23 it('getContentFromKVAsset', async () => {24 let content = await getContentFromKVAsset('not-found.txt')25 expect(content).toBeFalsy()26 content = await getContentFromKVAsset('index.html')27 expect(content).toBeTruthy()28 expect(content).toBe('This is index')29 content = await getContentFromKVAsset('assets/static/plain.txt')30 expect(content).toBeTruthy()31 expect(content).toBe('Asset text')32 })33})