mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
wip: migrate to bun
This commit is contained in:
48
test/isSet.spec.ts
Normal file
48
test/isSet.spec.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { set, falsey, stubFalse, args, slice, symbol, weakSet, realm } from './utils';
|
||||
import isSet from '../src/isSet';
|
||||
|
||||
describe('isSet', () => {
|
||||
it('should return `true` for sets', () => {
|
||||
if (Set) {
|
||||
assert.strictEqual(isSet(set), true);
|
||||
}
|
||||
});
|
||||
|
||||
it('should return `false` for non-sets', () => {
|
||||
const expected = lodashStable.map(falsey, stubFalse);
|
||||
|
||||
const actual = lodashStable.map(falsey, (value, index) => (index ? isSet(value) : isSet()));
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
|
||||
assert.strictEqual(isSet(args), false);
|
||||
assert.strictEqual(isSet([1, 2, 3]), false);
|
||||
assert.strictEqual(isSet(true), false);
|
||||
assert.strictEqual(isSet(new Date()), false);
|
||||
assert.strictEqual(isSet(new Error()), false);
|
||||
assert.strictEqual(isSet(slice), false);
|
||||
assert.strictEqual(isSet({ a: 1 }), false);
|
||||
assert.strictEqual(isSet(1), false);
|
||||
assert.strictEqual(isSet(/x/), false);
|
||||
assert.strictEqual(isSet('a'), false);
|
||||
assert.strictEqual(isSet(symbol), false);
|
||||
assert.strictEqual(isSet(weakSet), false);
|
||||
});
|
||||
|
||||
it('should work for objects with a non-function `constructor` (test in IE 11)', () => {
|
||||
const values = [false, true],
|
||||
expected = lodashStable.map(values, stubFalse);
|
||||
|
||||
const actual = lodashStable.map(values, (value) => isSet({ constructor: value }));
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should work with weak sets from another realm', () => {
|
||||
if (realm.set) {
|
||||
assert.strictEqual(isSet(realm.set), true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user