-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathunique.test.js
More file actions
47 lines (41 loc) · 1.3 KB
/
unique.test.js
File metadata and controls
47 lines (41 loc) · 1.3 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
39
40
41
42
43
44
45
46
47
// FIXME: npm test /src/utils/unique.test.js
const { unique } = require('./util');
describe('unique 테스트', () => {
describe('non-lazy', () => {
it('case: 1, Normal', () => {
const [firstArray, secondArray] = [
[2, 1, 2],
[1, 2, 1],
];
const firstUniqueArray = unique(firstArray);
const secondUniqueArray = unique(secondArray);
expect(firstUniqueArray).toEqual([2, 1]);
expect(secondUniqueArray).toEqual([1, 2]);
});
it('case: 2, Advanced', () => {
const [firstArray, secondArray, thirdArray] = [
[1, 2, 3],
[1, 1, 2, 2, 3],
[1, 2, 3, 3, 3, 3, 3],
];
const firstUniqueArray = unique(firstArray, undefined, true);
const secondUniqueArray = unique(secondArray, undefined, true);
const thirdUniqueArray = unique(thirdArray, undefined, true);
expect(firstUniqueArray).toEqual([1, 2, 3]);
expect(secondUniqueArray).toEqual([1, 2, 3]);
expect(thirdUniqueArray).toEqual([1, 2, 3]);
});
it('case: 3, Advanced', () => {
const objects = [
{ x: 1, y: 2 },
{ x: 2, y: 1 },
{ x: 1, y: 2 },
];
const uniqueObjects = unique(objects);
expect(uniqueObjects).toEqual([
{ x: 1, y: 2 },
{ x: 2, y: 1 },
]);
});
});
});