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