From 3ee06c57e5b33166c1af213338bb3da2dafd5995 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Sun, 23 Jun 2024 16:33:06 -0400 Subject: [PATCH] test: add a test Thanks to @jordydhoker for contributing this test: https://github.com/sodiray/radash/pull/343 --- src/tests/array.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tests/array.test.ts b/src/tests/array.test.ts index 15b1fc88..688da919 100644 --- a/src/tests/array.test.ts +++ b/src/tests/array.test.ts @@ -390,6 +390,26 @@ describe('array module', () => { assert.equal(c.id, 'c') assert.equal(c.word, '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) + assert.deepEqual(result, [ + null, + true, + 'true', + false, + { id: 'a', word: 'hello' } + ]) + }) }) describe('range function', () => {