mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
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:
committed by
John-David Dalton
parent
7606ea3e25
commit
d5ef31929a
55
test/isInteger-methods.js
Normal file
55
test/isInteger-methods.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import assert from 'assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { _, stubTrue, MAX_INTEGER, stubFalse, falsey, args, symbol } from './utils.js';
|
||||
|
||||
describe('isInteger methods', function() {
|
||||
lodashStable.each(['isInteger', 'isSafeInteger'], function(methodName) {
|
||||
var func = _[methodName],
|
||||
isSafe = methodName == 'isSafeInteger';
|
||||
|
||||
it('`_.' + methodName + '` should return `true` for integer values', function() {
|
||||
var values = [-1, 0, 1],
|
||||
expected = lodashStable.map(values, stubTrue);
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return func(value);
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
assert.strictEqual(func(MAX_INTEGER), !isSafe);
|
||||
});
|
||||
|
||||
it('should return `false` for non-integer number values', function() {
|
||||
var values = [NaN, Infinity, -Infinity, Object(1), 3.14],
|
||||
expected = lodashStable.map(values, stubFalse);
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return func(value);
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should return `false` for non-numeric values', function() {
|
||||
var expected = lodashStable.map(falsey, function(value) {
|
||||
return value === 0;
|
||||
});
|
||||
|
||||
var actual = lodashStable.map(falsey, function(value, index) {
|
||||
return index ? func(value) : func();
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
|
||||
assert.strictEqual(func(args), false);
|
||||
assert.strictEqual(func([1, 2, 3]), false);
|
||||
assert.strictEqual(func(true), false);
|
||||
assert.strictEqual(func(new Date), false);
|
||||
assert.strictEqual(func(new Error), false);
|
||||
assert.strictEqual(func({ 'a': 1 }), false);
|
||||
assert.strictEqual(func(/x/), false);
|
||||
assert.strictEqual(func('a'), false);
|
||||
assert.strictEqual(func(symbol), false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user