mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Add unit tests for _.countBy, _.groupBy, _.indexBy, and _.sortBy for when a callback is not passed.
Former-commit-id: e3c1760607cb86fc6c3729409d217b4255fb695d
This commit is contained in:
20
test/test.js
20
test/test.js
@@ -581,6 +581,11 @@
|
|||||||
QUnit.module('lodash.countBy');
|
QUnit.module('lodash.countBy');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
test('should use `_.identity` when no `callback` is passed', function() {
|
||||||
|
var actual = _.countBy([4, 6, 6]);
|
||||||
|
deepEqual(actual, { '4': 1, '6': 2 });
|
||||||
|
});
|
||||||
|
|
||||||
test('should support the `thisArg` argument', function() {
|
test('should support the `thisArg` argument', function() {
|
||||||
var actual = _.countBy([4.2, 6.1, 6.4], function(num) {
|
var actual = _.countBy([4.2, 6.1, 6.4], function(num) {
|
||||||
return this.floor(num);
|
return this.floor(num);
|
||||||
@@ -1424,6 +1429,11 @@
|
|||||||
QUnit.module('lodash.groupBy');
|
QUnit.module('lodash.groupBy');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
test('should use `_.identity` when no `callback` is passed', function() {
|
||||||
|
var actual = _.groupBy([4, 6, 6]);
|
||||||
|
deepEqual(actual, { '4': [4], '6': [6, 6] });
|
||||||
|
});
|
||||||
|
|
||||||
test('should support the `thisArg` argument', function() {
|
test('should support the `thisArg` argument', function() {
|
||||||
var actual = _.groupBy([4.2, 6.1, 6.4], function(num) {
|
var actual = _.groupBy([4.2, 6.1, 6.4], function(num) {
|
||||||
return this.floor(num);
|
return this.floor(num);
|
||||||
@@ -1466,6 +1476,11 @@
|
|||||||
QUnit.module('lodash.indexBy');
|
QUnit.module('lodash.indexBy');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
test('should use `_.identity` when no `callback` is passed', function() {
|
||||||
|
var actual = _.indexBy([4, 6, 6]);
|
||||||
|
deepEqual(actual, { '4': 4, '6': 6 });
|
||||||
|
});
|
||||||
|
|
||||||
test('should support the `thisArg` argument', function() {
|
test('should support the `thisArg` argument', function() {
|
||||||
var actual = _.indexBy([4.2, 6.1, 6.4], function(num) {
|
var actual = _.indexBy([4.2, 6.1, 6.4], function(num) {
|
||||||
return this.floor(num);
|
return this.floor(num);
|
||||||
@@ -3004,6 +3019,11 @@
|
|||||||
deepEqual(actual, collection);
|
deepEqual(actual, collection);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should use `_.identity` when no `callback` is passed', function() {
|
||||||
|
var actual = _.sortBy([3, 2, 1]);
|
||||||
|
deepEqual(actual, [1, 2, 3]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should support the `thisArg` argument', function() {
|
test('should support the `thisArg` argument', function() {
|
||||||
var actual = _.sortBy([1, 2, 3], function(num) {
|
var actual = _.sortBy([1, 2, 3], function(num) {
|
||||||
return this.sin(num);
|
return this.sin(num);
|
||||||
|
|||||||
Reference in New Issue
Block a user