source: imaps-frontend/node_modules/is-number-object/test/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3var test = require('tape');
4var isNumber = require('../');
5var hasToStringTag = require('has-tostringtag/shams')();
6
7test('not Numbers', function (t) {
8 t.notOk(isNumber(), 'undefined is not Number');
9 t.notOk(isNumber(null), 'null is not Number');
10 t.notOk(isNumber(false), 'false is not Number');
11 t.notOk(isNumber(true), 'true is not Number');
12 t.notOk(isNumber('foo'), 'string is not Number');
13 t.notOk(isNumber([]), 'array is not Number');
14 t.notOk(isNumber({}), 'object is not Number');
15 t.notOk(isNumber(function () {}), 'function is not Number');
16 t.notOk(isNumber(/a/g), 'regex literal is not Number');
17 t.notOk(isNumber(new RegExp('a', 'g')), 'regex object is not Number');
18 t.notOk(isNumber(new Date()), 'new Date() is not Number');
19 t.end();
20});
21
22test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
23 var fakeNumber = {
24 toString: function () { return '7'; },
25 valueOf: function () { return 42; }
26 };
27 fakeNumber[Symbol.toStringTag] = 'Number';
28 t.notOk(isNumber(fakeNumber), 'fake Number with @@toStringTag "Number" is not Number');
29 t.end();
30});
31
32test('Numbers', function (t) {
33 t.ok(isNumber(42), 'number is Number');
34 t.ok(isNumber(Object(42)), 'number object is Number');
35 t.ok(isNumber(NaN), 'NaN is Number');
36 t.ok(isNumber(Infinity), 'Infinity is Number');
37 t.end();
38});
Note: See TracBrowser for help on using the repository browser.