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.

JestHooks.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _defineProperty(obj, key, value) {
  7. if (key in obj) {
  8. Object.defineProperty(obj, key, {
  9. value: value,
  10. enumerable: true,
  11. configurable: true,
  12. writable: true
  13. });
  14. } else {
  15. obj[key] = value;
  16. }
  17. return obj;
  18. }
  19. /**
  20. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  21. *
  22. * This source code is licensed under the MIT license found in the
  23. * LICENSE file in the root directory of this source tree.
  24. */
  25. class JestHooks {
  26. constructor() {
  27. _defineProperty(this, '_listeners', void 0);
  28. _defineProperty(this, '_subscriber', void 0);
  29. _defineProperty(this, '_emitter', void 0);
  30. this._listeners = {
  31. onFileChange: [],
  32. onTestRunComplete: [],
  33. shouldRunTestSuite: []
  34. };
  35. this._subscriber = {
  36. onFileChange: fn => {
  37. this._listeners.onFileChange.push(fn);
  38. },
  39. onTestRunComplete: fn => {
  40. this._listeners.onTestRunComplete.push(fn);
  41. },
  42. shouldRunTestSuite: fn => {
  43. this._listeners.shouldRunTestSuite.push(fn);
  44. }
  45. };
  46. this._emitter = {
  47. onFileChange: fs =>
  48. this._listeners.onFileChange.forEach(listener => listener(fs)),
  49. onTestRunComplete: results =>
  50. this._listeners.onTestRunComplete.forEach(listener =>
  51. listener(results)
  52. ),
  53. shouldRunTestSuite: async testSuiteInfo => {
  54. const result = await Promise.all(
  55. this._listeners.shouldRunTestSuite.map(listener =>
  56. listener(testSuiteInfo)
  57. )
  58. );
  59. return result.every(Boolean);
  60. }
  61. };
  62. }
  63. isUsed(hook) {
  64. var _this$_listeners$hook;
  65. return (
  66. ((_this$_listeners$hook = this._listeners[hook]) === null ||
  67. _this$_listeners$hook === void 0
  68. ? void 0
  69. : _this$_listeners$hook.length) > 0
  70. );
  71. }
  72. getSubscriber() {
  73. return this._subscriber;
  74. }
  75. getEmitter() {
  76. return this._emitter;
  77. }
  78. }
  79. var _default = JestHooks;
  80. exports.default = _default;