Add initial test files from lodash v4. (#4172)

* 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.
This commit is contained in:
Benjamin Tan
2019-02-13 01:11:32 +08:00
committed by John-David Dalton
parent 7606ea3e25
commit d5ef31929a
311 changed files with 22361 additions and 0 deletions

47
test/isIterateeCall.js Normal file
View File

@@ -0,0 +1,47 @@
import assert from 'assert';
import { MAX_SAFE_INTEGER } from './utils.js';
import _isIterateeCall from '../.internal/isIterateeCall.js';
describe('isIterateeCall', function() {
var array = [1],
func = _isIterateeCall,
object = { 'a': 1 };
it('should return `true` for iteratee calls', function() {
function Foo() {}
Foo.prototype.a = 1;
if (func) {
assert.strictEqual(func(1, 0, array), true);
assert.strictEqual(func(1, 'a', object), true);
assert.strictEqual(func(1, 'a', new Foo), true);
}
});
it('should return `false` for non-iteratee calls', function() {
if (func) {
assert.strictEqual(func(2, 0, array), false);
assert.strictEqual(func(1, 1.1, array), false);
assert.strictEqual(func(1, 0, { 'length': MAX_SAFE_INTEGER + 1 }), false);
assert.strictEqual(func(1, 'b', object), false);
}
});
it('should work with `NaN` values', function() {
if (func) {
assert.strictEqual(func(NaN, 0, [NaN]), true);
assert.strictEqual(func(NaN, 'a', { 'a': NaN }), true);
}
});
it('should not error when `index` is an object without a `toString` method', function() {
if (func) {
try {
var actual = func(1, { 'toString': null }, [1]);
} catch (e) {
var message = e.message;
}
assert.strictEqual(actual, false, message || '');
}
});
});