Skip to content

Commit

Permalink
test(@toss/utils): Add uniq Function Test Code (toss#315)
Browse files Browse the repository at this point in the history
* test(@toss/utils): Add uniq Function Test Code

* fix(@toss/utils): Fix uniq Function Test Code
  • Loading branch information
ssi02014 authored Jul 26, 2023
1 parent b091824 commit 2e28e77
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/common/utils/src/uniq.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { uniq } from './uniq';

describe('uniq', () => {
it('should return an array', () => {
const inputList = [1, 2, 3, 4, 5];
const uniqOutputList = uniq(inputList);

expect(Array.isArray(uniqOutputList)).toBeTruthy();
});

it('should return an empty array if an empty array is passed as an argument', () => {
expect(uniq([])).toEqual([]);
});

it('should remove duplicate values from a array', () => {
const inputList = [1, 2, 1, 3, 2, 4, 1, 5, 1];
const expectedList = [1, 2, 3, 4, 5];

const uniqOutputList = uniq(inputList);

expect(uniqOutputList).toEqual(expectedList);
expect(uniqOutputList.length).toBe(expectedList.length);
});

it('should return an array with the same values as the original array if there are no duplicates', () => {
const inputList = [1, 2, 3, 4, 5];
const expectedList = [1, 2, 3, 4, 5];

const uniqOutputList = uniq(inputList);

expect(uniqOutputList).toEqual(expectedList);
expect(uniqOutputList.length).toBe(expectedList.length);
});
});

0 comments on commit 2e28e77

Please sign in to comment.