-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathunique-array-of.spec.ts
More file actions
38 lines (36 loc) · 1.13 KB
/
unique-array-of.spec.ts
File metadata and controls
38 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* eslint-disable sonarjs/no-hardcoded-ip */
import {uniqueArrayOf} from '@angular-ru/cdk/array';
describe('[TEST]: unique array of', () => {
it('unique list from duplicate', () => {
expect(
uniqueArrayOf(
[
{id: 1, value: 2},
{id: 2, value: 3},
{id: 1, value: 4},
],
(item) => item.id,
),
).toEqual([
{id: 1, value: 2},
{id: 2, value: 3},
]);
});
it('unique list from duplicate deep path', () => {
expect(
uniqueArrayOf(
[
{ip: '1.2.3.4', info: {username: 'a'}},
{ip: '1.2.3.5', info: {username: 'a'}},
{ip: '1.2.3.6', info: {username: 'b'}},
{ip: '1.2.3.7', info: {username: 'c'}},
],
'info.username',
),
).toEqual([
{ip: '1.2.3.4', info: {username: 'a'}},
{ip: '1.2.3.6', info: {username: 'b'}},
{ip: '1.2.3.7', info: {username: 'c'}},
]);
});
});