* 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
18 lines
635 B
JavaScript
Executable File
18 lines
635 B
JavaScript
Executable File
const { filterFalsy } = require('./_30s.js');
|
|
|
|
test('filterFalsy is a Function', () => {
|
|
expect(filterFalsy).toBeInstanceOf(Function);
|
|
});
|
|
|
|
test('filterFalsy filters different types of falsy values', () => {
|
|
expect(filterFalsy(['', true, {}, false, 'sample', 1, 0])).toEqual([true, {}, 'sample', 1]);
|
|
});
|
|
|
|
test('filterFalsy returns an empty array if you pass it an array of falsy values', () => {
|
|
expect(filterFalsy(['', 0, false, '', false, 0])).toEqual([]);
|
|
});
|
|
|
|
test('filterFalsy returns all of the truthy elements in an array', () => {
|
|
expect(filterFalsy([true, null, 'test', {}, []])).toEqual([true, 'test', {}, []]);
|
|
});
|