Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

shimmed.js 1.2KB

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