forked from Kong/httpsnippet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.test.ts
More file actions
39 lines (35 loc) · 1.4 KB
/
headers.test.ts
File metadata and controls
39 lines (35 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { getHeader, getHeaderName, hasHeader } from './headers';
const headers = {
'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001',
accept: 'application/json',
};
describe('headers', () => {
describe('getHeader', () => {
it('should get a header', () => {
expect(getHeader(headers, 'content-type')).toBe(
'multipart/form-data; boundary=---011000010111000001101001',
);
expect(getHeader(headers, 'content-TYPE')).toBe(
'multipart/form-data; boundary=---011000010111000001101001',
);
expect(getHeader(headers, 'Accept')).toBe('application/json');
expect(getHeader(headers, 'authorization')).toBeUndefined();
});
});
describe('getHeaderName', () => {
it('should get a header name', () => {
expect(getHeaderName(headers, 'content-type')).toBe('Content-Type');
expect(getHeaderName(headers, 'content-TYPE')).toBe('Content-Type');
expect(getHeaderName(headers, 'Accept')).toBe('accept');
expect(getHeaderName(headers, 'authorization')).toBeUndefined();
});
});
describe('hasHeader', () => {
it('should return if a header is present', () => {
expect(hasHeader(headers, 'content-type')).toBe(true);
expect(hasHeader(headers, 'content-TYPE')).toBe(true);
expect(hasHeader(headers, 'Accept')).toBe(true);
expect(hasHeader(headers, 'authorization')).toBe(false);
});
});
});