Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5061ec
commit 740796e
Showing
2 changed files
with
31 additions
and
34 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,29 @@ | ||
import { getName } from '../../test/util'; | ||
import { sampleSize } from '.'; | ||
|
||
describe(getName(__filename), () => { | ||
describe('sampleSize', () => { | ||
const array = ['a', 'b', 'c', 'd']; | ||
it('returns correct sized array', () => { | ||
expect(sampleSize(array, 2)).toHaveLength(2); | ||
}); | ||
it('returns full array for undefined number', () => { | ||
expect(sampleSize(array, undefined)).toEqual(array); | ||
}); | ||
it('returns full array for null number', () => { | ||
expect(sampleSize(array, null)).toEqual([]); | ||
}); | ||
it('returns full array for 0 number', () => { | ||
expect(sampleSize(array, 0)).toEqual([]); | ||
}); | ||
it('returns empty array for null array', () => { | ||
expect(sampleSize(null, 1)).toEqual([]); | ||
}); | ||
it('returns empty array for undefined array', () => { | ||
expect(sampleSize(undefined, 1)).toEqual([]); | ||
}); | ||
it('returns empty array for empty array', () => { | ||
expect(sampleSize([], 1)).toEqual([]); | ||
}); | ||
}); | ||
}); |
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