Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jestMatchersObject.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.setMatchers =
  6. exports.getMatchers =
  7. exports.setState =
  8. exports.getState =
  9. exports.INTERNAL_MATCHER_FLAG =
  10. void 0;
  11. var _asymmetricMatchers = require('./asymmetricMatchers');
  12. var global = (function () {
  13. if (typeof globalThis !== 'undefined') {
  14. return globalThis;
  15. } else if (typeof global !== 'undefined') {
  16. return global;
  17. } else if (typeof self !== 'undefined') {
  18. return self;
  19. } else if (typeof window !== 'undefined') {
  20. return window;
  21. } else {
  22. return Function('return this')();
  23. }
  24. })();
  25. var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
  26. // Global matchers object holds the list of available matchers and
  27. // the state, that can hold matcher specific values that change over time.
  28. const JEST_MATCHERS_OBJECT = Symbol.for('$$jest-matchers-object'); // Notes a built-in/internal Jest matcher.
  29. // Jest may override the stack trace of Errors thrown by internal matchers.
  30. const INTERNAL_MATCHER_FLAG = Symbol.for('$$jest-internal-matcher');
  31. exports.INTERNAL_MATCHER_FLAG = INTERNAL_MATCHER_FLAG;
  32. if (!global.hasOwnProperty(JEST_MATCHERS_OBJECT)) {
  33. const defaultState = {
  34. assertionCalls: 0,
  35. expectedAssertionsNumber: null,
  36. isExpectingAssertions: false,
  37. suppressedErrors: [] // errors that are not thrown immediately.
  38. };
  39. Object.defineProperty(global, JEST_MATCHERS_OBJECT, {
  40. value: {
  41. matchers: Object.create(null),
  42. state: defaultState
  43. }
  44. });
  45. }
  46. const getState = () => global[JEST_MATCHERS_OBJECT].state;
  47. exports.getState = getState;
  48. const setState = state => {
  49. Object.assign(global[JEST_MATCHERS_OBJECT].state, state);
  50. };
  51. exports.setState = setState;
  52. const getMatchers = () => global[JEST_MATCHERS_OBJECT].matchers;
  53. exports.getMatchers = getMatchers;
  54. const setMatchers = (matchers, isInternal, expect) => {
  55. Object.keys(matchers).forEach(key => {
  56. const matcher = matchers[key];
  57. Object.defineProperty(matcher, INTERNAL_MATCHER_FLAG, {
  58. value: isInternal
  59. });
  60. if (!isInternal) {
  61. // expect is defined
  62. class CustomMatcher extends _asymmetricMatchers.AsymmetricMatcher {
  63. constructor(inverse = false, ...sample) {
  64. super(sample);
  65. this.inverse = inverse;
  66. }
  67. asymmetricMatch(other) {
  68. const {pass} = matcher(other, ...this.sample);
  69. return this.inverse ? !pass : pass;
  70. }
  71. toString() {
  72. return `${this.inverse ? 'not.' : ''}${key}`;
  73. }
  74. getExpectedType() {
  75. return 'any';
  76. }
  77. toAsymmetricMatcher() {
  78. return `${this.toString()}<${this.sample.map(String).join(', ')}>`;
  79. }
  80. }
  81. expect[key] = (...sample) => new CustomMatcher(false, ...sample);
  82. if (!expect.not) {
  83. expect.not = {};
  84. }
  85. expect.not[key] = (...sample) => new CustomMatcher(true, ...sample);
  86. }
  87. });
  88. Object.assign(global[JEST_MATCHERS_OBJECT].matchers, matchers);
  89. };
  90. exports.setMatchers = setMatchers;