handler.test.ts
This file
Path
src/adapter/lambda-edge/handler.test.ts
38 lines · 1.6 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 7ee829b point at it.
v4.4.7Yusuke Wadabefore adoption7ee829b
lines 1–38why, one step back1import { encodeBase64 } from '../../utils/encode'2import { createBody, isContentTypeBinary } from './handler'34describe('isContentTypeBinary', () => {5 it('Should determine whether it is binary', () => {6 expect(isContentTypeBinary('image/png')).toBe(true)7 expect(isContentTypeBinary('font/woff2')).toBe(true)8 expect(isContentTypeBinary('image/svg+xml')).toBe(false)9 expect(isContentTypeBinary('image/svg+xml; charset=UTF-8')).toBe(false)10 expect(isContentTypeBinary('text/plain')).toBe(false)11 expect(isContentTypeBinary('text/plain; charset=UTF-8')).toBe(false)12 expect(isContentTypeBinary('text/css')).toBe(false)13 expect(isContentTypeBinary('text/javascript')).toBe(false)14 expect(isContentTypeBinary('application/json')).toBe(false)15 expect(isContentTypeBinary('application/ld+json')).toBe(false)16 expect(isContentTypeBinary('application/json; charset=UTF-8')).toBe(false)17 })18})1920describe('createBody', () => {21 it('Should the request be a GET or HEAD, the Request must not include a Body', () => {22 const encoder = new TextEncoder()23 const data = encoder.encode('test')24 const body = {25 action: 'read-only',26 data: encodeBase64(data),27 encoding: 'base64',28 inputTruncated: false,29 }3031 expect(createBody('GET', body)).toEqual(undefined)32 expect(createBody('GET', body)).not.toEqual(data)33 expect(createBody('HEAD', body)).toEqual(undefined)34 expect(createBody('HEAD', body)).not.toEqual(data)35 expect(createBody('POST', body)).toEqual(data)36 expect(createBody('POST', body)).not.toEqual(undefined)37 })38})