Node-Red configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

tests.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. // eslint-disable-next-line consistent-return
  3. module.exports = function runSymbolTests(t) {
  4. t.equal(typeof Symbol, 'function', 'global Symbol is a function');
  5. if (typeof Symbol !== 'function') { return false; }
  6. t.notEqual(Symbol(), Symbol(), 'two symbols are not equal');
  7. /*
  8. t.equal(
  9. Symbol.prototype.toString.call(Symbol('foo')),
  10. Symbol.prototype.toString.call(Symbol('foo')),
  11. 'two symbols with the same description stringify the same'
  12. );
  13. */
  14. /*
  15. var foo = Symbol('foo');
  16. t.notEqual(
  17. String(foo),
  18. String(Symbol('bar')),
  19. 'two symbols with different descriptions do not stringify the same'
  20. );
  21. */
  22. t.equal(typeof Symbol.prototype.toString, 'function', 'Symbol#toString is a function');
  23. // t.equal(String(foo), Symbol.prototype.toString.call(foo), 'Symbol#toString equals String of the same symbol');
  24. t.equal(typeof Object.getOwnPropertySymbols, 'function', 'Object.getOwnPropertySymbols is a function');
  25. var obj = {};
  26. var sym = Symbol('test');
  27. var symObj = Object(sym);
  28. t.notEqual(typeof sym, 'string', 'Symbol is not a string');
  29. t.equal(Object.prototype.toString.call(sym), '[object Symbol]', 'symbol primitive Object#toStrings properly');
  30. t.equal(Object.prototype.toString.call(symObj), '[object Symbol]', 'symbol primitive Object#toStrings properly');
  31. var symVal = 42;
  32. obj[sym] = symVal;
  33. // eslint-disable-next-line no-restricted-syntax
  34. for (sym in obj) { t.fail('symbol property key was found in for..in of object'); }
  35. t.deepEqual(Object.keys(obj), [], 'no enumerable own keys on symbol-valued object');
  36. t.deepEqual(Object.getOwnPropertyNames(obj), [], 'no own names on symbol-valued object');
  37. t.deepEqual(Object.getOwnPropertySymbols(obj), [sym], 'one own symbol on symbol-valued object');
  38. t.equal(Object.prototype.propertyIsEnumerable.call(obj, sym), true, 'symbol is enumerable');
  39. t.deepEqual(Object.getOwnPropertyDescriptor(obj, sym), {
  40. configurable: true,
  41. enumerable: true,
  42. value: 42,
  43. writable: true
  44. }, 'property descriptor is correct');
  45. };