@platform/http
Version:
Tools for working with HTTP.
28 lines (27 loc) • 1.09 kB
JavaScript
import { expect } from '../test';
import * as util from './util';
describe('util', () => {
it('headerValue', () => {
const test = (key, headers, expected) => {
const res = util.headerValue(key, headers);
expect(res).to.eql(expected);
};
test('foo', undefined, '');
test('foo', {}, '');
test('content-type', { 'content-type': 'text/plain' }, 'text/plain');
test('content-type', { 'Content-Type': 'text/plain' }, 'text/plain');
test(' content-type ', { 'Content-Type': 'text/plain' }, 'text/plain');
test('content-type', { ' Content-Type ': 'text/plain' }, 'text/plain');
});
it('isFormData', () => {
const test = (headers, expected) => {
const res = util.isFormData(headers);
expect(res).to.eql(expected);
};
test(undefined, false);
test({}, false);
test({ foo: 'hello' }, false);
test({ 'content-type': 'multipart/form-data' }, true);
test({ ' Content-Type ': ' multipart/form-data ' }, true);
});
});