0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-03-15 08:34:54 +00:00
renovatebot_renovate/lib/util/uniq.spec.ts
renovate[bot] 55845508b6
chore(deps): update eslint monorepo to v9 (major) (#33573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-02-20 11:31:13 +00:00

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);
});
});