mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
* test: fix throttle.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix pickBy.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix isBuffer.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: partially fix attempt.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: partially fix dropRightWhile.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix defer.spec.js and rest.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix invoke.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix isArray.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: partially fix iteration-methods.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix xor-methods.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix property.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix ary.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix omit-methods.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix debounce-and-throttle.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix unzip-and-zip.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix toPairs-methods.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix exit-early.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: temporarily comment out takeWhile and dropWhile tests Signed-off-by: tison <wander4096@gmail.com> * test: partially fix union*.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix startsWith-and-endsWith.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix isNil.spec.js Signed-off-by: tison <wander4096@gmail.com> * test: fix some of syntax errors Signed-off-by: tison <wander4096@gmail.com> --------- Signed-off-by: tison <wander4096@gmail.com>
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import lodashStable from 'lodash';
|
|
import { falsey, stubFalse, args, slice, symbol, isStrict, lodashBizarro } from './utils';
|
|
import isBuffer from '../src/isBuffer';
|
|
|
|
describe('isBuffer', () => {
|
|
it('should return `true` for buffers', () => {
|
|
if (Buffer) {
|
|
expect(isBuffer(Buffer.alloc(2))).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('should return `false` for non-buffers', () => {
|
|
const expected = lodashStable.map(falsey, stubFalse);
|
|
|
|
const actual = lodashStable.map(falsey, (value, index) =>
|
|
index ? isBuffer(value) : isBuffer(),
|
|
);
|
|
|
|
expect(actual).toEqual(expected);
|
|
|
|
expect(isBuffer(args)).toBe(false);
|
|
expect(isBuffer([1])).toBe(false);
|
|
expect(isBuffer(true)).toBe(false);
|
|
expect(isBuffer(new Date())).toBe(false);
|
|
expect(isBuffer(new Error())).toBe(false);
|
|
expect(isBuffer(slice)).toBe(false);
|
|
expect(isBuffer({ a: 1 })).toBe(false);
|
|
expect(isBuffer(1)).toBe(false);
|
|
expect(isBuffer(/x/)).toBe(false);
|
|
expect(isBuffer('a')).toBe(false);
|
|
expect(isBuffer(symbol)).toBe(false);
|
|
});
|
|
|
|
it('should return `false` if `Buffer` is not defined', () => {
|
|
if (!isStrict && Buffer && lodashBizarro) {
|
|
expect(lodashBizarro.isBuffer(Buffer.alloc(2))).toBe(false);
|
|
}
|
|
});
|
|
});
|