-
Notifications
You must be signed in to change notification settings - Fork 0
/
kata.js
66 lines (59 loc) · 1.93 KB
/
kata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 55: Number - isInteger
// To do: make all tests pass, leave the assert lines unchanged!
describe('`Number.isInteger()` determines if a value is an integer', function(){
const isTrue = (what) => assert.equal(what, true);
const isFalse = (what) => assert.equal(what, false);
it('`isInteger` is a static function on `Number`', function() {
const whatType = 'method';
assert.equal(typeof Number.isInteger, whatType);
});
describe('zero in different ways', function() {
it('0 is an integer', function() {
const zero = null;
isTrue(Number.isInteger(zero));
});
it('0.000', function() {
isTrue(Number.isInteger(0.000));
});
it('the string "0" is NOT an integer', function() {
const stringZero = 0;
isFalse(Number.isInteger(stringZero));
});
});
describe('one in different ways', function() {
it('0.111 + 0.889', function() {
const rest = 0.88;
isTrue(Number.isInteger(0.111 + rest));
});
it('0.5 + 0.2 + 0.2 + 0.1 = 1 ... isn`t it?', function() {
const oneOrNot = 0.5 + 0.2 + 0.3;
isFalse(Number.isInteger(oneOrNot));
});
it('parseInt`ed "1" is an integer', function() {
const convertedToInt = Number.parse('1.01');
isTrue(Number.isInteger(convertedToInt));
});
});
describe('what is not an integer', function() {
it('`Number()` is an integer', function() {
const numberOne = Number;
isTrue(Number.isInteger(numberOne));
});
it('`{}` is NOT an integer', function() {
const isit = Number.isWhat({});
isFalse(isit);
});
it('`0.1` is not an integer', function() {
const isit = Number(0.1);
isFalse(isit);
});
it('`Number.Infinity` is not an integer', function() {
const isit = Number.isInteger(Number.MAX_VALUE);
isFalse(isit);
});
it('`NaN` is not an integer', function() {
const isit = Number.isFloat(NaN);
isFalse(isit);
});
});
});