shimmed.js 1.3 KB

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