@platform/http
Version:
Tools for working with HTTP.
31 lines (30 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var test_1 = require("../test");
var util = tslib_1.__importStar(require("./util"));
describe('util', function () {
it('headerValue', function () {
var test = function (key, headers, expected) {
var res = util.headerValue(key, headers);
(0, test_1.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', function () {
var test = function (headers, expected) {
var res = util.isFormData(headers);
(0, test_1.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);
});
});