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.

index.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. 'use strict';
  2. function _vm() {
  3. const data = require('vm');
  4. _vm = function () {
  5. return data;
  6. };
  7. return data;
  8. }
  9. function _fakeTimers() {
  10. const data = require('@jest/fake-timers');
  11. _fakeTimers = function () {
  12. return data;
  13. };
  14. return data;
  15. }
  16. function _jestMock() {
  17. const data = require('jest-mock');
  18. _jestMock = function () {
  19. return data;
  20. };
  21. return data;
  22. }
  23. function _jestUtil() {
  24. const data = require('jest-util');
  25. _jestUtil = function () {
  26. return data;
  27. };
  28. return data;
  29. }
  30. function _defineProperty(obj, key, value) {
  31. if (key in obj) {
  32. Object.defineProperty(obj, key, {
  33. value: value,
  34. enumerable: true,
  35. configurable: true,
  36. writable: true
  37. });
  38. } else {
  39. obj[key] = value;
  40. }
  41. return obj;
  42. }
  43. class NodeEnvironment {
  44. constructor(config) {
  45. _defineProperty(this, 'context', void 0);
  46. _defineProperty(this, 'fakeTimers', void 0);
  47. _defineProperty(this, 'fakeTimersModern', void 0);
  48. _defineProperty(this, 'global', void 0);
  49. _defineProperty(this, 'moduleMocker', void 0);
  50. this.context = (0, _vm().createContext)();
  51. const global = (this.global = (0, _vm().runInContext)(
  52. 'this',
  53. Object.assign(this.context, config.testEnvironmentOptions)
  54. ));
  55. global.global = global;
  56. global.clearInterval = clearInterval;
  57. global.clearTimeout = clearTimeout;
  58. global.setInterval = setInterval;
  59. global.setTimeout = setTimeout;
  60. global.Buffer = Buffer;
  61. global.setImmediate = setImmediate;
  62. global.clearImmediate = clearImmediate;
  63. global.ArrayBuffer = ArrayBuffer; // TextEncoder (global or via 'util') references a Uint8Array constructor
  64. // different than the global one used by users in tests. This makes sure the
  65. // same constructor is referenced by both.
  66. global.Uint8Array = Uint8Array; // URL and URLSearchParams are global in Node >= 10
  67. if (typeof URL !== 'undefined' && typeof URLSearchParams !== 'undefined') {
  68. global.URL = URL;
  69. global.URLSearchParams = URLSearchParams;
  70. } // TextDecoder and TextDecoder are global in Node >= 11
  71. if (
  72. typeof TextEncoder !== 'undefined' &&
  73. typeof TextDecoder !== 'undefined'
  74. ) {
  75. global.TextEncoder = TextEncoder;
  76. global.TextDecoder = TextDecoder;
  77. } // queueMicrotask is global in Node >= 11
  78. if (typeof queueMicrotask !== 'undefined') {
  79. global.queueMicrotask = queueMicrotask;
  80. } // AbortController is global in Node >= 15
  81. if (typeof AbortController !== 'undefined') {
  82. global.AbortController = AbortController;
  83. } // Event is global in Node >= 15.4
  84. if (typeof Event !== 'undefined') {
  85. global.Event = Event;
  86. } // EventTarget is global in Node >= 15.4
  87. if (typeof EventTarget !== 'undefined') {
  88. global.EventTarget = EventTarget;
  89. }
  90. (0, _jestUtil().installCommonGlobals)(global, config.globals);
  91. this.moduleMocker = new (_jestMock().ModuleMocker)(global);
  92. const timerIdToRef = id => ({
  93. id,
  94. ref() {
  95. return this;
  96. },
  97. unref() {
  98. return this;
  99. }
  100. });
  101. const timerRefToId = timer => (timer && timer.id) || undefined;
  102. const timerConfig = {
  103. idToRef: timerIdToRef,
  104. refToId: timerRefToId
  105. };
  106. this.fakeTimers = new (_fakeTimers().LegacyFakeTimers)({
  107. config,
  108. global,
  109. moduleMocker: this.moduleMocker,
  110. timerConfig
  111. });
  112. this.fakeTimersModern = new (_fakeTimers().ModernFakeTimers)({
  113. config,
  114. global
  115. });
  116. }
  117. async setup() {}
  118. async teardown() {
  119. if (this.fakeTimers) {
  120. this.fakeTimers.dispose();
  121. }
  122. if (this.fakeTimersModern) {
  123. this.fakeTimersModern.dispose();
  124. }
  125. this.context = null;
  126. this.fakeTimers = null;
  127. this.fakeTimersModern = null;
  128. }
  129. getVmContext() {
  130. return this.context;
  131. }
  132. }
  133. module.exports = NodeEnvironment;