1fc59cd022779599363bdaf4c68ddbf995372d97e184b7696a2d80f9e3ff0446cc343a1c34510d1d15540cfe726ccb2963b3c9cb52d7a1352d4e496c5c55b3 1.3 KB

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