fakes.js 683 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var inspect = require('../');
  3. var test = require('tape');
  4. var hasToStringTag = require('has-tostringtag/shams')();
  5. var forEach = require('for-each');
  6. test('fakes', { skip: !hasToStringTag }, function (t) {
  7. forEach([
  8. 'Array',
  9. 'Boolean',
  10. 'Date',
  11. 'Error',
  12. 'Number',
  13. 'RegExp',
  14. 'String'
  15. ], function (expected) {
  16. var faker = {};
  17. faker[Symbol.toStringTag] = expected;
  18. t.equal(
  19. inspect(faker),
  20. '{ [Symbol(Symbol.toStringTag)]: \'' + expected + '\' }',
  21. 'faker masquerading as ' + expected + ' is not shown as one'
  22. );
  23. });
  24. t.end();
  25. });