source: trip-planner-front/node_modules/is-arguments/test/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2
3var test = require('tape');
4var isArguments = require('../');
5var hasToStringTag = require('has-tostringtag/shams')();
6
7test('primitives', function (t) {
8 t.notOk(isArguments([]), 'array is not arguments');
9 t.notOk(isArguments({}), 'object is not arguments');
10 t.notOk(isArguments(''), 'empty string is not arguments');
11 t.notOk(isArguments('foo'), 'string is not arguments');
12 t.notOk(isArguments({ length: 2 }), 'naive array-like is not arguments');
13 t.end();
14});
15
16test('arguments object', function (t) {
17 t.ok(isArguments(arguments), 'arguments is arguments');
18 t.notOk(isArguments(Array.prototype.slice.call(arguments)), 'sliced arguments is not arguments');
19 t.end();
20});
21
22test('old-style arguments object', function (t) {
23 var isLegacyArguments = isArguments.isLegacyArguments || isArguments;
24 var fakeOldArguments = {
25 callee: function () {},
26 length: 3
27 };
28 t.ok(isLegacyArguments(fakeOldArguments), 'old-style arguments is arguments');
29 t.end();
30});
31
32test('Symbol.toStringTag', { skip: !hasToStringTag }, function (t) {
33 var obj = {};
34 obj[Symbol.toStringTag] = 'Arguments';
35 t.notOk(isArguments(obj), 'object with faked toStringTag is not arguments');
36
37 var args = (function () {
38 return arguments;
39 }());
40 args[Symbol.toStringTag] = 'Arguments';
41 t.notOk(isArguments(obj), 'real arguments with faked toStringTag is not arguments');
42
43 t.end();
44});
Note: See TracBrowser for help on using the repository browser.