Skip to content

Commit fa4d984

Browse files
committed
Add missing tests for array utilities
1 parent 56e9c4b commit fa4d984

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { uniqueBasedOnHash } from '../array'
2+
3+
describe('uniqueBasedOnHash', () => {
4+
it('returns a list of unique elements', () => {
5+
type Item = { x: string; y: number }
6+
7+
const items: Item[] = [
8+
{ x: '1', y: 1 },
9+
{ x: '1', y: 2 },
10+
{ x: '2', y: 3 },
11+
]
12+
13+
const hashFunction = ({ x }: Item) => x
14+
const result = uniqueBasedOnHash(items, hashFunction)
15+
expect(result).toEqual([
16+
{ x: '1', y: 1 },
17+
{ x: '2', y: 3 },
18+
])
19+
})
20+
})

0 commit comments

Comments
 (0)