add filterFalsy snippet, tags, and tests

This commit is contained in:
Mykolas Krupauskas
2018-10-29 23:19:01 +02:00
parent 41735984c1
commit 5c693aee76
3 changed files with 32 additions and 0 deletions

18
test/filterFalsy.test.js Executable file
View File

@ -0,0 +1,18 @@
const expect = require('expect');
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', {}, []]);
});