Skip to content
Myr

utils.test.ts

This file

Path

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

33 lines · 977 bytes · TypeScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than f0b094d point at it.

Merge commit from forkYusuke Wadabefore adoptionf0b094d

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})