source: imaps-frontend/node_modules/which-boxed-primitive/test/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var test = require('tape');
4var inspect = require('object-inspect');
5var forEach = require('for-each');
6var v = require('es-value-fixtures');
7
8var whichBoxedPrimitive = require('../');
9
10var objects = [
11 /a/g,
12 new Date(),
13 function () {},
14 [],
15 {}
16].concat(v.objects);
17
18test('isBoxedPrimitive', function (t) {
19 t.test('unboxed primitives', function (st) {
20 forEach(v.primitives, function (primitive) {
21 st.equal(null, whichBoxedPrimitive(primitive), inspect(primitive) + ' is a primitive, but not a boxed primitive');
22 });
23 st.end();
24 });
25
26 t.test('boxed primitives', function (st) {
27 forEach(v.primitives, function (primitive) {
28 if (primitive != null) { // eslint-disable-line eqeqeq
29 var boxed = Object(primitive);
30 var expected = boxed.constructor.name;
31 st.equal(typeof expected, 'string', 'expected is string');
32 st.equal(whichBoxedPrimitive(boxed), expected, inspect(boxed) + ' is a boxed primitive: ' + expected);
33 }
34 });
35 st.end();
36 });
37
38 t.test('non-primitive objects', function (st) {
39 forEach(objects, function (object) {
40 st.equal(undefined, whichBoxedPrimitive(object), inspect(object) + ' is not a primitive, boxed or otherwise');
41 });
42 st.end();
43 });
44
45 t.end();
46});
Note: See TracBrowser for help on using the repository browser.