16fb2bb919
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
27 lines
701 B
JavaScript
27 lines
701 B
JavaScript
import chai from 'chai';
|
|
const { expect } = chai;
|
|
import find from '../../src/utils/find';
|
|
|
|
describe('utils/find', () => {
|
|
const arr = [
|
|
{ id: 1, value: '1v' },
|
|
{ id: 2, value: '2v' },
|
|
{ id: 3, value: '2v' },
|
|
{ id: 4, value: '2v' },
|
|
];
|
|
|
|
it('should find correct element in an array', () => {
|
|
expect(find(arr, el => el.id === 1)).to.deep.equal({ id: 1, value: '1v' });
|
|
});
|
|
|
|
it('should return the fist found element', () => {
|
|
expect(find(arr, el => el.value === '2v')).to.deep.equal({
|
|
id: 2,
|
|
value: '2v',
|
|
});
|
|
});
|
|
|
|
it('should return undefined if nothing is found', () => {
|
|
expect(find(arr, el => el.value === '3v')).to.equal(undefined);
|
|
});
|
|
});
|