import assert from 'assert'; import utils from '../../../lib/utils.js'; import FormData from 'form-data'; import stream from 'stream'; describe('utils', function (){ it('should validate Stream', function () { assert.strictEqual(utils.isStream(new stream.Readable()),true); assert.strictEqual(utils.isStream({ foo: 'bar' }),false); }); it('should validate Buffer', function () { assert.strictEqual(utils.isBuffer(Buffer.from('a')),true); assert.strictEqual(utils.isBuffer(null),false); assert.strictEqual(utils.isBuffer(undefined),false); }); describe('utils::isFormData', function () { it('should detect the FormData instance provided by the `form-data` package', function () { [1, 'str', {}, new RegExp()].forEach(function (thing) { assert.equal(utils.isFormData(thing), false); }); assert.equal(utils.isFormData(new FormData()), true); }); }); });