* chore: make aware eslint that we use jest By setting up the jest environment, we no longer need to declare the 'test' global in the configuration. * chore: don't need to import expect, it's a jest environment global * chore: don't need to import expect when creating undefined test
12 lines
471 B
JavaScript
12 lines
471 B
JavaScript
const {groupBy} = require('./_30s.js');
|
|
|
|
test('groupBy is a Function', () => {
|
|
expect(groupBy).toBeInstanceOf(Function);
|
|
});
|
|
test('Groups the elements of an array based on the given function', () => {
|
|
expect(groupBy([6.1, 4.2, 6.3], Math.floor)).toEqual({ 4: [4.2], 6: [6.1, 6.3] });
|
|
});
|
|
test('Groups the elements of an array based on the given function', () => {
|
|
expect(groupBy(['one', 'two', 'three'], 'length')).toEqual({ 3: ['one', 'two'], 5: ['three'] });
|
|
});
|