mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Add fromIndex to _.contains.
Former-commit-id: 9f61db3ceda2d87ddfbfd4cffb2bd1f9732cc79a
This commit is contained in:
@@ -636,6 +636,7 @@
|
||||
equal(object.fn(), 2, '_.bind: ' + basename);
|
||||
|
||||
ok(lodash.clone(array, true)[0] === array[0], '_.clone should be shallow: ' + basename);
|
||||
equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename);
|
||||
equal(lodash.every([true, false, true]), false, '_.every: ' + basename);
|
||||
|
||||
object = { 'length': 0, 'splice': Array.prototype.splice };
|
||||
|
||||
27
test/test.js
27
test/test.js
@@ -262,6 +262,33 @@
|
||||
QUnit.module('lodash.contains');
|
||||
|
||||
(function() {
|
||||
_.each({
|
||||
'an array': [1, 2, 3, 1, 2, 3],
|
||||
'an object': { 'a': 1, 'b': 2, 'c': 3, 'd': 1, 'e': 2, 'f': 3 },
|
||||
'a string': '123123'
|
||||
},
|
||||
function(collection, key) {
|
||||
test('should work with ' + key + ' and a positive `fromIndex`', function() {
|
||||
equal(_.contains(collection, 1, 2), true);
|
||||
});
|
||||
|
||||
test('should work with ' + key + ' and a `fromIndex` >= collection\'s length', function() {
|
||||
equal(_.contains(collection, 1, 6), false);
|
||||
equal(_.contains(collection, undefined, 6), false);
|
||||
equal(_.contains(collection, 1, 8), false);
|
||||
equal(_.contains(collection, undefined, 8), false);
|
||||
});
|
||||
|
||||
test('should work with ' + key + ' and a negative `fromIndex`', function() {
|
||||
equal(_.contains(collection, 2, -3), true);
|
||||
});
|
||||
|
||||
test('should work with ' + key + ' and a negative `fromIndex` <= negative collection\'s length', function() {
|
||||
equal(_.contains(collection, 1, -6), true);
|
||||
equal(_.contains(collection, 2, -8), true);
|
||||
});
|
||||
});
|
||||
|
||||
_.each({
|
||||
'literal': 'abc',
|
||||
'object': Object('abc')
|
||||
|
||||
Reference in New Issue
Block a user