forked from toss/slash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(@toss/utils): Add uniq Function Test Code (toss#315)
* test(@toss/utils): Add uniq Function Test Code * fix(@toss/utils): Fix uniq Function Test Code
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |