mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Update vendor/underscore to v1.5.0.
Former-commit-id: 8f647bccfdd8fe81473ae7d1354056a928b6f28c
This commit is contained in:
16
vendor/underscore/test/chaining.js
vendored
16
vendor/underscore/test/chaining.js
vendored
@@ -17,15 +17,15 @@ $(document).ready(function() {
|
||||
hash[l]++;
|
||||
return hash;
|
||||
}, {}).value();
|
||||
ok(counts['a'] == 16 && counts['e'] == 10, 'counted all the letters in the song');
|
||||
ok(counts.a == 16 && counts.e == 10, 'counted all the letters in the song');
|
||||
});
|
||||
|
||||
test("select/reject/sortBy", function() {
|
||||
var numbers = [1,2,3,4,5,6,7,8,9,10];
|
||||
numbers = _(numbers).chain().select(function(n) {
|
||||
return n % 2 == 0;
|
||||
return n % 2 === 0;
|
||||
}).reject(function(n) {
|
||||
return n % 4 == 0;
|
||||
return n % 4 === 0;
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
@@ -35,9 +35,9 @@ $(document).ready(function() {
|
||||
test("select/reject/sortBy in functional style", function() {
|
||||
var numbers = [1,2,3,4,5,6,7,8,9,10];
|
||||
numbers = _.chain(numbers).select(function(n) {
|
||||
return n % 2 == 0;
|
||||
return n % 2 === 0;
|
||||
}).reject(function(n) {
|
||||
return n % 4 == 0;
|
||||
return n % 4 === 0;
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
@@ -56,4 +56,10 @@ $(document).ready(function() {
|
||||
equal(numbers.join(', '), "34, 10, 8, 6, 4, 2, 10, 10", 'can chain together array functions.');
|
||||
});
|
||||
|
||||
test("chaining works in small stages", function() {
|
||||
var o = _([1, 2, 3, 4]).chain();
|
||||
deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
|
||||
deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user