9da3baba8ad94b5ece5616ff36da348e4bde6c92e437e214aa27928a50483e36ddd478436bfb6f8d5eaf5c62a08d48b66918dfd804aa9cb15494785c0978e1 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.trimStart.length, 0, 'String#trimStart has a length of 0');
  11. t.test('Function name', { skip: !functionsHaveNames }, function (st) {
  12. st.equal((/^(?:trimLeft|trimStart)$/).test(String.prototype.trimStart.name), true, 'String#trimStart has name "trimLeft" or "trimStart"');
  13. st.end();
  14. });
  15. t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
  16. et.equal(false, isEnumerable.call(String.prototype, 'trimStart'), 'String#trimStart 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.trimStart.call(undefined, 'a'); }, TypeError, 'undefined is not an object');
  22. st['throws'](function () { return String.prototype.trimStart.call(null, 'a'); }, TypeError, 'null is not an object');
  23. st.end();
  24. });
  25. runTests(callBind(String.prototype.trimStart), t);
  26. t.end();
  27. });