cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/responses.test.ts

25lines · modecode

1import { createResponseHeaders } from 'cloudflare/core';
2import { Headers } from 'cloudflare/_shims/index';
3
4describe('response parsing', () => {
5 // TODO: test unicode characters
6 test('headers are case agnostic', async () => {
7 const headers = createResponseHeaders(new Headers({ 'Content-Type': 'foo', Accept: 'text/plain' }));
8 expect(headers['content-type']).toEqual('foo');
9 expect(headers['Content-type']).toEqual('foo');
10 expect(headers['Content-Type']).toEqual('foo');
11 expect(headers['accept']).toEqual('text/plain');
12 expect(headers['Accept']).toEqual('text/plain');
13 expect(headers['Hello-World']).toBeUndefined();
14 });
15
16 test('duplicate headers are concatenated', () => {
17 const headers = createResponseHeaders(
18 new Headers([
19 ['Content-Type', 'text/xml'],
20 ['Content-Type', 'application/json'],
21 ]),
22 );
23 expect(headers['content-type']).toBe('text/xml, application/json');
24 });
25});
26