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
RevLine 
[d565449]1'use strict';
2
3var test = require('tape');
4var inspect = require('object-inspect');
[79a0317]5var forEach = require('for-each');
6var v = require('es-value-fixtures');
[d565449]7
[79a0317]8var whichBoxedPrimitive = require('../');
[d565449]9
10var objects = [
11 /a/g,
12 new Date(),
13 function () {},
14 [],
15 {}
[79a0317]16].concat(v.objects);
[d565449]17
18test('isBoxedPrimitive', function (t) {
19 t.test('unboxed primitives', function (st) {
[79a0317]20 forEach(v.primitives, function (primitive) {
21 st.equal(null, whichBoxedPrimitive(primitive), inspect(primitive) + ' is a primitive, but not a boxed primitive');
[d565449]22 });
23 st.end();
24 });
25
26 t.test('boxed primitives', function (st) {
[79a0317]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 }
[d565449]34 });
35 st.end();
36 });
37
38 t.test('non-primitive objects', function (st) {
39 forEach(objects, function (object) {
[79a0317]40 st.equal(undefined, whichBoxedPrimitive(object), inspect(object) + ' is not a primitive, boxed or otherwise');
[d565449]41 });
42 st.end();
43 });
44
45 t.end();
46});
Note: See TracBrowser for help on using the repository browser.