mirror of
https://github.com/renovatebot/renovate.git
synced 2025-03-15 08:34:54 +00:00
![renovate[bot]](/assets/img/avatar_default.png)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
19 lines
597 B
TypeScript
19 lines
597 B
TypeScript
import { uniq } from './uniq';
|
|
|
|
describe('util/uniq', () => {
|
|
it('should return an array with unique elements', () => {
|
|
const input = [1, 2, 3, 2, 1, 4];
|
|
const expectedOutput = [1, 2, 3, 4];
|
|
expect(uniq(input)).toEqual(expectedOutput);
|
|
});
|
|
|
|
it('should use the provided equality function to compare elements', () => {
|
|
interface T {
|
|
id: number;
|
|
}
|
|
const input: T[] = [{ id: 1 }, { id: 2 }, { id: 1 }];
|
|
const expectedOutput = [{ id: 1 }, { id: 2 }];
|
|
const eql = (x: T, y: T) => x.id === y.id;
|
|
expect(uniq(input, eql)).toEqual(expectedOutput);
|
|
});
|
|
});
|