Test cleanup and fixes [c-d]
This commit is contained in:
@ -8,15 +8,33 @@ const toSafeInteger = require('./toSafeInteger.js');
|
||||
test('Number(toSafeInteger(3.2)) is a number', () => {
|
||||
expect(Number(toSafeInteger(3.2))).toBeTruthy();
|
||||
});
|
||||
t.equal(toSafeInteger(3.2), 3, "Converts a value to a safe integer");
|
||||
t.equal(toSafeInteger('4.2'), 4, "toSafeInteger('4.2') returns 4");
|
||||
t.equal(toSafeInteger(4.6), 5, "toSafeInteger(4.6) returns 5");
|
||||
t.equal(toSafeInteger([]), 0, "toSafeInteger([]) returns 0");
|
||||
t.true(isNaN(toSafeInteger([1.5, 3124])), "isNaN(toSafeInteger([1.5, 3124])) is true");
|
||||
t.true(isNaN(toSafeInteger('string')), "isNaN(toSafeInteger('string')) is true");
|
||||
t.true(isNaN(toSafeInteger({})), "isNaN(toSafeInteger({})) is true");
|
||||
t.true(isNaN(toSafeInteger()), "isNaN(toSafeInteger()) is true");
|
||||
t.equal(toSafeInteger(Infinity), 9007199254740991, "toSafeInteger(Infinity) returns 9007199254740991");
|
||||
test('Converts a value to a safe integer', () => {
|
||||
expect(toSafeInteger(3.2)).toBe(3)
|
||||
});
|
||||
test('toSafeInteger('4.2') returns 4', () => {
|
||||
expect(toSafeInteger('4.2')).toBe(4)
|
||||
});
|
||||
test('toSafeInteger(4.6) returns 5', () => {
|
||||
expect(toSafeInteger(4.6)).toBe(5)
|
||||
});
|
||||
test('toSafeInteger([]) returns 0', () => {
|
||||
expect(toSafeInteger([])).toBe(0)
|
||||
});
|
||||
test('isNaN(toSafeInteger([1.5, 3124])) is true', () => {
|
||||
expect(isNaN(toSafeInteger([1.5, 3124]))).toBeTruthy()
|
||||
});
|
||||
test('isNaN(toSafeInteger('string')) is true', () => {
|
||||
expect(isNaN(toSafeInteger('string'))).toBeTruthy()
|
||||
});
|
||||
test('isNaN(toSafeInteger({})) is true', () => {
|
||||
expect(isNaN(toSafeInteger({}))).toBeTruthy()
|
||||
});
|
||||
test('isNaN(toSafeInteger()) is true', () => {
|
||||
expect(isNaN(toSafeInteger())).toBeTruthy()
|
||||
});
|
||||
test('toSafeInteger(Infinity) returns 9007199254740991', () => {
|
||||
expect(toSafeInteger(Infinity)).toBe(9007199254740991)
|
||||
});
|
||||
|
||||
let start = new Date().getTime();
|
||||
toSafeInteger(3.2);
|
||||
|
||||
Reference in New Issue
Block a user