mirror of
https://github.com/Snigdha-OS/documentation.git
synced 2025-09-10 19:54:57 +02:00
23 lines
613 B
JavaScript
23 lines
613 B
JavaScript
import test from 'ava';
|
|
import unique from './unique';
|
|
|
|
test('it filters duplicated entries', (t) => {
|
|
const duplicated = ['two', 'four'];
|
|
const raw = ['one', 'two', 'three', 'four'];
|
|
const filtered = unique([...raw, ...duplicated]);
|
|
|
|
duplicated.forEach((dup) => {
|
|
t.true(filtered.filter((item) => item === dup).length === 1);
|
|
});
|
|
});
|
|
|
|
test('should work with null/undefined values', (t) => {
|
|
const falsy = [null, undefined];
|
|
const raw = ['one', 'two', 'three', 'four'];
|
|
const filtered = unique([...raw, ...falsy]);
|
|
|
|
falsy.forEach((value) => {
|
|
t.true(filtered.includes(value));
|
|
});
|
|
});
|