1 | 'use strict';
|
2 |
|
3 | var nativeIsInteger = require('../src/integer/native'),
|
4 | polyfillIsInteger = require('../src/integer/polyfill'),
|
5 | isInteger = require('../src/integer'),
|
6 | assert = require('chai').assert;
|
7 |
|
8 | describe('integer', function() {
|
9 | it('picks native or polyfill function', function() {
|
10 | assert.ok(isInteger === nativeIsInteger || isInteger === polyfillIsInteger);
|
11 | });
|
12 |
|
13 | ['native', 'polyfill'].forEach(function(type) {
|
14 | var isInteger = type === 'native' ? nativeIsInteger : polyfillIsInteger;
|
15 |
|
16 | (typeof isInteger === 'undefined' ? describe.skip : describe)(type, function() {
|
17 | it('returns false if value is not a number', function() {
|
18 | assert.ok(isInteger(NaN) === false);
|
19 | assert.ok(isInteger('') === false);
|
20 | assert.ok(isInteger('1') === false);
|
21 | });
|
22 |
|
23 | it('returns false if value is not an integer', function() {
|
24 | assert.ok(isInteger(10.1) === false);
|
25 | assert.ok(isInteger(-9.23) === false);
|
26 | });
|
27 |
|
28 | it('returns true if value is an integer', function() {
|
29 | assert.ok(isInteger(1));
|
30 | assert.ok(isInteger(201));
|
31 | });
|
32 | });
|
33 | });
|
34 | });
|