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.
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
import assert from 'assert';
|
|
import lodashStable from 'lodash';
|
|
import { args, strictArgs, falsey, stubFalse, slice, noop, symbol, realm } from './utils.js';
|
|
import isArguments from '../isArguments.js';
|
|
|
|
describe('isArguments', function() {
|
|
it('should return `true` for `arguments` objects', function() {
|
|
assert.strictEqual(isArguments(args), true);
|
|
assert.strictEqual(isArguments(strictArgs), true);
|
|
});
|
|
|
|
it('should return `false` for non `arguments` objects', function() {
|
|
var expected = lodashStable.map(falsey, stubFalse);
|
|
|
|
var actual = lodashStable.map(falsey, function(value, index) {
|
|
return index ? isArguments(value) : isArguments();
|
|
});
|
|
|
|
assert.deepStrictEqual(actual, expected);
|
|
|
|
assert.strictEqual(isArguments([1, 2, 3]), false);
|
|
assert.strictEqual(isArguments(true), false);
|
|
assert.strictEqual(isArguments(new Date), false);
|
|
assert.strictEqual(isArguments(new Error), false);
|
|
assert.strictEqual(isArguments(_), false);
|
|
assert.strictEqual(isArguments(slice), false);
|
|
assert.strictEqual(isArguments({ '0': 1, 'callee': noop, 'length': 1 }), false);
|
|
assert.strictEqual(isArguments(1), false);
|
|
assert.strictEqual(isArguments(/x/), false);
|
|
assert.strictEqual(isArguments('a'), false);
|
|
assert.strictEqual(isArguments(symbol), false);
|
|
});
|
|
|
|
it('should work with an `arguments` object from another realm', function() {
|
|
if (realm.arguments) {
|
|
assert.strictEqual(isArguments(realm.arguments), true);
|
|
}
|
|
});
|
|
});
|