-
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.
fix(Module): Add uniq and docs (#10)
- Loading branch information
1 parent
1afad62
commit 5277e58
Showing
4 changed files
with
40 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
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,19 @@ | ||
import uniq from '../../modules/uniq' | ||
|
||
describe('uniq', () => { | ||
test('returns an array of unique values', () => { | ||
const arr = [1, 2, 3, 4, 1] | ||
const actual = uniq(arr) | ||
const expected = [1, 2, 3, 4] | ||
|
||
expect(actual).toEqual(expected) | ||
}) | ||
|
||
test('returns a copy of the passed in array', () => { | ||
const arr = [1, 2, 3] | ||
const actual = uniq(arr) | ||
|
||
expect(actual).not.toBe(arr) | ||
expect(actual).toEqual(arr) | ||
}) | ||
}) |
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
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,3 @@ | ||
const uniq = arr => Array.from(new Set(arr)) | ||
|
||
export default uniq |