Skip to content

Commit

Permalink
test: add a test
Browse files Browse the repository at this point in the history
Thanks to @jordydhoker for contributing this test: sodiray/radash#343
  • Loading branch information
aleclarson committed Jun 25, 2024
1 parent 4154fb8 commit da224ea
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/array/tests/unique.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,24 @@ describe('unique function', () => {
expect(c.id).toBe('c')
expect(c.word).toBe('yolo')
})
test('correctly handles non string, number or symbol values', () => {
const list: any[] = [
null,
null,
true,
true,
'true',
false,
{ id: 'a', word: 'hello' },
{ id: 'a', word: 'hello' }
]
const result = _.unique(list, val => (val && val.id) ?? val)
expect(result).toEqual([
null,
true,
'true',
false,
{ id: 'a', word: 'hello' }
])
})
})

0 comments on commit da224ea

Please sign in to comment.