Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
@ -2,5 +2,5 @@ const countBy = (arr, fn) =>
|
||||
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
||||
acc[val] = (acc[val] || 0) + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
}, {
|
||||
module.exports = countBy;
|
||||
@ -1,10 +1,11 @@
|
||||
const expect = require('expect');
|
||||
const countBy = require('./countBy.js');
|
||||
|
||||
test('Testing countBy', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
expect(typeof countBy === 'function').toBeTruthy();
|
||||
expect(countBy([6.1, 4.2, 6.3], Math.floor)).toEqual({4: 1, 6: 2});
|
||||
expect(countBy(['one', 'two', 'three'], 'length')).toEqual({3: 2, 5: 1});
|
||||
|
||||
test('countBy is a Function', () => {
|
||||
expect(countBy).toBeInstanceOf(Function);
|
||||
});
|
||||
t.deepEqual(countBy([6.1, 4.2, 6.3], Math.floor), {4: 1, 6: 2}, 'Works for functions');
|
||||
t.deepEqual(countBy(['one', 'two', 'three'], 'length'), {3: 2, 5: 1}, 'Works for property names');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user