mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57: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
52
test/dropRightWhile.js
Normal file
52
test/dropRightWhile.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import assert from 'assert';
|
||||
import { slice } from './utils.js';
|
||||
import dropRightWhile from '../dropRightWhile.js';
|
||||
|
||||
describe('dropRightWhile', function() {
|
||||
var array = [1, 2, 3, 4];
|
||||
|
||||
var objects = [
|
||||
{ 'a': 0, 'b': 0 },
|
||||
{ 'a': 1, 'b': 1 },
|
||||
{ 'a': 2, 'b': 2 }
|
||||
];
|
||||
|
||||
it('should drop elements while `predicate` returns truthy', function() {
|
||||
var actual = dropRightWhile(array, function(n) {
|
||||
return n > 2;
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, [1, 2]);
|
||||
});
|
||||
|
||||
it('should provide correct `predicate` arguments', function() {
|
||||
var args;
|
||||
|
||||
dropRightWhile(array, function() {
|
||||
args = slice.call(arguments);
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(args, [4, 3, array]);
|
||||
});
|
||||
|
||||
it('should work with `_.matches` shorthands', function() {
|
||||
assert.deepStrictEqual(dropRightWhile(objects, { 'b': 2 }), objects.slice(0, 2));
|
||||
});
|
||||
|
||||
it('should work with `_.matchesProperty` shorthands', function() {
|
||||
assert.deepStrictEqual(dropRightWhile(objects, ['b', 2]), objects.slice(0, 2));
|
||||
});
|
||||
|
||||
it('should work with `_.property` shorthands', function() {
|
||||
assert.deepStrictEqual(dropRightWhile(objects, 'b'), objects.slice(0, 1));
|
||||
});
|
||||
|
||||
it('should return a wrapped value when chaining', function() {
|
||||
var wrapped = _(array).dropRightWhile(function(n) {
|
||||
return n > 2;
|
||||
});
|
||||
|
||||
assert.ok(wrapped instanceof _);
|
||||
assert.deepEqual(wrapped.value(), [1, 2]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user