mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
* Install test dependencies. * Add initial test files. These files were created using a simplistic AST manipulator using `recast` to preserve formatting. There's bound to be a huge chunk of errors, but this serves as a good start. QUnit was replaced with Mocha, with ES2015 imports running via `esm`. As far as possible, QUnit-specific syntax has been replaced with Mocha's `describe` and `it`, while the native Node.js `assert` module is used for assertions. Files in the `test` directory ending in `.test.js` will be treated as test files. * Add initial passing files to test run.
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import assert from 'assert';
|
|
import lodashStable from 'lodash';
|
|
import { weakSet, falsey, stubFalse, args, slice, set, symbol, realm } from './utils.js';
|
|
import isWeakSet from '../isWeakSet.js';
|
|
|
|
describe('isWeakSet', function() {
|
|
it('should return `true` for weak sets', function() {
|
|
if (WeakSet) {
|
|
assert.strictEqual(isWeakSet(weakSet), true);
|
|
}
|
|
});
|
|
|
|
it('should return `false` for non weak sets', function() {
|
|
var expected = lodashStable.map(falsey, stubFalse);
|
|
|
|
var actual = lodashStable.map(falsey, function(value, index) {
|
|
return 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(_), 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', function() {
|
|
if (realm.weakSet) {
|
|
assert.strictEqual(isWeakSet(realm.weakSet), true);
|
|
}
|
|
});
|
|
});
|