Migrated tests to jest
Used jest-codemods to migrate, will have to pass everything by hand before we can merge.
This commit is contained in:
3
test6/toSafeInteger/toSafeInteger.js
Normal file
3
test6/toSafeInteger/toSafeInteger.js
Normal file
@ -0,0 +1,3 @@
|
||||
const toSafeInteger = num =>
|
||||
Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER));
|
||||
module.exports = toSafeInteger;
|
||||
23
test6/toSafeInteger/toSafeInteger.test.js
Normal file
23
test6/toSafeInteger/toSafeInteger.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
const expect = require('expect');
|
||||
const toSafeInteger = require('./toSafeInteger.js');
|
||||
|
||||
test('Testing toSafeInteger', () => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
expect(typeof toSafeInteger === 'function').toBeTruthy();
|
||||
expect(Number(toSafeInteger(3.2))).toBeTruthy();
|
||||
expect(toSafeInteger(3.2)).toBe(3);
|
||||
expect(toSafeInteger('4.2')).toBe(4);
|
||||
expect(toSafeInteger(4.6)).toBe(5);
|
||||
expect(toSafeInteger([])).toBe(0);
|
||||
expect(isNaN(toSafeInteger([1.5, 3124]))).toBeTruthy();
|
||||
expect(isNaN(toSafeInteger('string'))).toBeTruthy();
|
||||
expect(isNaN(toSafeInteger({}))).toBeTruthy();
|
||||
expect(isNaN(toSafeInteger())).toBeTruthy();
|
||||
expect(toSafeInteger(Infinity)).toBe(9007199254740991);
|
||||
|
||||
let start = new Date().getTime();
|
||||
toSafeInteger(3.2);
|
||||
let end = new Date().getTime();
|
||||
expect((end - start) < 2000).toBeTruthy();
|
||||
});
|
||||
Reference in New Issue
Block a user