source: imaps-frontend/node_modules/array-includes/test/shimmed.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
Line 
1'use strict';
2
3var orig = Array.prototype.includes;
4
5require('../auto');
6
7var test = require('tape');
8var defineProperties = require('define-properties');
9var callBind = require('call-bind');
10var isEnumerable = Object.prototype.propertyIsEnumerable;
11var functionsHaveNames = require('functions-have-names')();
12
13var runTests = require('./tests');
14
15test('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});
Note: See TracBrowser for help on using the repository browser.