blob: 7081eb17541299e1f003d67ac4987e3a7958d08a [file] [log] [blame]
Tim van der Lippefdbd42e2020-04-07 15:14:36 +01001'use strict';
2
Tim van der Lippe2c891972021-07-29 16:22:50 +01003require('../auto');
Tim van der Lippefdbd42e2020-04-07 15:14:36 +01004
5var test = require('tape');
6var defineProperties = require('define-properties');
7var bind = require('function-bind');
8var isEnumerable = Object.prototype.propertyIsEnumerable;
9var functionsHaveNames = require('functions-have-names')();
10
11var runTests = require('./tests');
12
13test('shimmed', function (t) {
14 t.equal(Array.prototype.includes.length, 1, 'Array#includes has a length of 1');
15 t.test('Function name', { skip: !functionsHaveNames }, function (st) {
16 st.equal(Array.prototype.includes.name, 'includes', 'Array#includes has name "includes"');
17 st.end();
18 });
19
20 t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
21 et.equal(false, isEnumerable.call(Array.prototype, 'includes'), 'Array#includes is not enumerable');
22 et.end();
23 });
24
25 var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
26
27 t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
28 st['throws'](function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
29 st['throws'](function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
30 st.end();
31 });
32
33 runTests(bind.call(Function.call, Array.prototype.includes), t);
34
35 t.end();
36});