1 | 'use strict';
|
---|
2 |
|
---|
3 | var orig = Array.prototype.includes;
|
---|
4 |
|
---|
5 | require('../auto');
|
---|
6 |
|
---|
7 | var test = require('tape');
|
---|
8 | var defineProperties = require('define-properties');
|
---|
9 | var callBind = require('call-bind');
|
---|
10 | var isEnumerable = Object.prototype.propertyIsEnumerable;
|
---|
11 | var functionsHaveNames = require('functions-have-names')();
|
---|
12 |
|
---|
13 | var runTests = require('./tests');
|
---|
14 |
|
---|
15 | test('shimmed', function (t) {
|
---|
16 | t.comment('shimmed: ' + (orig === Array.prototype.includes ? 'no' : 'yes'));
|
---|
17 | t.equal(Array.prototype.includes.length, 1, 'Array#includes has a length of 1');
|
---|
18 | t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
---|
19 | st.equal(Array.prototype.includes.name, 'includes', 'Array#includes has name "includes"');
|
---|
20 | st.end();
|
---|
21 | });
|
---|
22 |
|
---|
23 | t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
---|
24 | et.equal(false, isEnumerable.call(Array.prototype, 'includes'), 'Array#includes is not enumerable');
|
---|
25 | et.end();
|
---|
26 | });
|
---|
27 |
|
---|
28 | var supportsStrictMode = (function () { return typeof this === 'undefined'; }());
|
---|
29 |
|
---|
30 | t.test('bad array/this value', { skip: !supportsStrictMode }, function (st) {
|
---|
31 | st['throws'](function () { return Array.prototype.includes.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
|
---|
32 | st['throws'](function () { return Array.prototype.includes.call(null, 'a'); }, TypeError, 'null is not an object');
|
---|
33 | st.end();
|
---|
34 | });
|
---|
35 |
|
---|
36 | runTests(callBind(Array.prototype.includes), t);
|
---|
37 |
|
---|
38 | t.end();
|
---|
39 | });
|
---|