Test migration to jest by hand

Apparently using regular expressions is way easier.
This commit is contained in:
Angelos Chalaris
2018-06-18 15:15:56 +03:00
parent 977949ca61
commit 4f7da1be9b
894 changed files with 5917 additions and 3607 deletions

View File

@ -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;

View File

@ -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');