mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
wip: code formatting nits continued
This commit is contained in:
21
test/toLength.spec.js
Normal file
21
test/toLength.spec.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { MAX_INTEGER, MAX_ARRAY_LENGTH } from './utils';
|
||||
import toLength from '../src/toLength';
|
||||
|
||||
describe('toLength', () => {
|
||||
it('should return a valid length', () => {
|
||||
expect(toLength(-1)).toBe(0);
|
||||
expect(toLength('1')).toBe(1);
|
||||
expect(toLength(1.1)).toBe(1);
|
||||
expect(toLength(MAX_INTEGER)).toBe(MAX_ARRAY_LENGTH);
|
||||
});
|
||||
|
||||
it('should return `value` if a valid length', () => {
|
||||
expect(toLength(0)).toBe(0);
|
||||
expect(toLength(3)).toBe(3);
|
||||
expect(toLength(MAX_ARRAY_LENGTH)).toBe(MAX_ARRAY_LENGTH);
|
||||
});
|
||||
|
||||
it('should convert `-0` to `0`', () => {
|
||||
expect(1 / toLength(-0)).toBe(Infinity);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user