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.
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import assert from 'assert';
|
|
import lodashStable from 'lodash';
|
|
import { _, args, strictArgs } from './utils.js';
|
|
|
|
describe('values methods', function() {
|
|
lodashStable.each(['values', 'valuesIn'], function(methodName) {
|
|
var func = _[methodName],
|
|
isValues = methodName == 'values';
|
|
|
|
it('`_.' + methodName + '` should get string keyed values of `object`', function() {
|
|
var object = { 'a': 1, 'b': 2 },
|
|
actual = func(object).sort();
|
|
|
|
assert.deepStrictEqual(actual, [1, 2]);
|
|
});
|
|
|
|
it('`_.' + methodName + '` should work with an object that has a `length` property', function() {
|
|
var object = { '0': 'a', '1': 'b', 'length': 2 },
|
|
actual = func(object).sort();
|
|
|
|
assert.deepStrictEqual(actual, [2, 'a', 'b']);
|
|
});
|
|
|
|
it('`_.' + methodName + '` should ' + (isValues ? 'not ' : '') + 'include inherited string keyed property values', function() {
|
|
function Foo() {
|
|
this.a = 1;
|
|
}
|
|
Foo.prototype.b = 2;
|
|
|
|
var expected = isValues ? [1] : [1, 2],
|
|
actual = func(new Foo).sort();
|
|
|
|
assert.deepStrictEqual(actual, expected);
|
|
});
|
|
|
|
it('`_.' + methodName + '` should work with `arguments` objects', function() {
|
|
var values = [args, strictArgs],
|
|
expected = lodashStable.map(values, lodashStable.constant([1, 2, 3]));
|
|
|
|
var actual = lodashStable.map(values, function(value) {
|
|
return func(value).sort();
|
|
});
|
|
|
|
assert.deepStrictEqual(actual, expected);
|
|
});
|
|
});
|
|
});
|