source: imaps-frontend/node_modules/is-boolean-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.6 KB
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var isBoolean = require('../');
5var hasToStringTag = require('has-tostringtag/shams')();
6
7test('not Booleans', function (t) {
8 t.test('primitives', function (st) {
9 st.notOk(isBoolean(), 'undefined is not Boolean');
10 st.notOk(isBoolean(null), 'null is not Boolean');
11 st.notOk(isBoolean(0), '0 is not Boolean');
12 st.notOk(isBoolean(NaN), 'NaN is not Boolean');
13 st.notOk(isBoolean(Infinity), 'Infinity is not Boolean');
14 st.notOk(isBoolean('foo'), 'string is not Boolean');
15 st.end();
16 });
17
18 t.test('objects', function (st) {
19 st.notOk(isBoolean(Object(42)), 'number object is not Boolean');
20 st.notOk(isBoolean([]), 'array is not Boolean');
21 st.notOk(isBoolean({}), 'object is not Boolean');
22 st.notOk(isBoolean(function () {}), 'function is not Boolean');
23 st.notOk(isBoolean(/a/g), 'regex literal is not Boolean');
24 st.notOk(isBoolean(new RegExp('a', 'g')), 'regex object is not Boolean');
25 st.notOk(isBoolean(new Date()), 'new Date() is not Boolean');
26 st.end();
27 });
28
29 t.end();
30});
31
32test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
33 var fakeBoolean = {
34 toString: function () { return 'true'; },
35 valueOf: function () { return true; }
36 };
37 fakeBoolean[Symbol.toStringTag] = 'Boolean';
38 t.notOk(isBoolean(fakeBoolean), 'fake Boolean with @@toStringTag "Boolean" is not Boolean');
39 t.end();
40});
41
42test('Booleans', function (t) {
43 t.ok(isBoolean(true), 'true is Boolean');
44 t.ok(isBoolean(false), 'false is Boolean');
45 t.ok(isBoolean(Object(true)), 'Object(true) is Boolean');
46 t.ok(isBoolean(Object(false)), 'Object(false) is Boolean');
47 t.end();
48});
Note: See TracBrowser for help on using the repository browser.