|
| 1 | +import test from 'ava' |
| 2 | +import {removeFalsy} from '../src' |
| 3 | + |
| 4 | +test('removes false from array', t => { |
| 5 | + const n = [false] |
| 6 | + const expected = [] |
| 7 | + const actual = removeFalsy(n) |
| 8 | + t.deepEqual(actual, expected) |
| 9 | +}) |
| 10 | + |
| 11 | +test('removes zero from array', t => { |
| 12 | + const n = [0] |
| 13 | + const expected = [] |
| 14 | + const actual = removeFalsy(n) |
| 15 | + t.deepEqual(actual, expected) |
| 16 | +}) |
| 17 | + |
| 18 | +test('removes empty string from array', t => { |
| 19 | + const n = [''] |
| 20 | + const expected = [] |
| 21 | + const actual = removeFalsy(n) |
| 22 | + t.deepEqual(actual, expected) |
| 23 | +}) |
| 24 | + |
| 25 | +test('removes null from array', t => { |
| 26 | + const n = [null] |
| 27 | + const expected = [] |
| 28 | + const actual = removeFalsy(n) |
| 29 | + t.deepEqual(actual, expected) |
| 30 | +}) |
| 31 | + |
| 32 | +test('removes undefined from array', t => { |
| 33 | + const n = [undefined] |
| 34 | + const expected = [] |
| 35 | + const actual = removeFalsy(n) |
| 36 | + t.deepEqual(actual, expected) |
| 37 | +}) |
| 38 | + |
| 39 | +test('removes NaN from array', t => { |
| 40 | + const n = [NaN] |
| 41 | + const expected = [] |
| 42 | + const actual = removeFalsy(n) |
| 43 | + t.deepEqual(actual, expected) |
| 44 | +}) |
| 45 | + |
| 46 | +test('maintains array order', t => { |
| 47 | + const n = [NaN, 1, 2, false, undefined, 3, 0, '', 4, 5, null] |
| 48 | + const expected = [1, 2, 3, 4, 5] |
| 49 | + const actual = removeFalsy(n) |
| 50 | + t.deepEqual(actual, expected) |
| 51 | +}) |
0 commit comments