@iobroker/testing 5.0.0 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/build/index.d.ts +1 -1
  4. package/build/lib/adapterTools.d.ts +7 -1
  5. package/build/lib/adapterTools.js +36 -21
  6. package/build/lib/executeCommand.d.ts +3 -2
  7. package/build/lib/executeCommand.js +30 -29
  8. package/build/lib/str2regex.js +4 -4
  9. package/build/tests/index.d.ts +9 -9
  10. package/build/tests/integration/index.d.ts +1 -1
  11. package/build/tests/integration/index.js +44 -39
  12. package/build/tests/integration/lib/adapterSetup.d.ts +1 -1
  13. package/build/tests/integration/lib/adapterSetup.js +50 -52
  14. package/build/tests/integration/lib/controllerSetup.d.ts +1 -10
  15. package/build/tests/integration/lib/controllerSetup.js +59 -56
  16. package/build/tests/integration/lib/dbConnection.d.ts +12 -12
  17. package/build/tests/integration/lib/dbConnection.js +71 -69
  18. package/build/tests/integration/lib/harness.d.ts +9 -7
  19. package/build/tests/integration/lib/harness.js +68 -49
  20. package/build/tests/integration/lib/logger.js +1 -1
  21. package/build/tests/integration/lib/tools.d.ts +6 -1
  22. package/build/tests/integration/lib/tools.js +27 -12
  23. package/build/tests/packageFiles/index.js +92 -90
  24. package/build/tests/unit/harness/createMocks.d.ts +3 -2
  25. package/build/tests/unit/harness/createMocks.js +0 -1
  26. package/build/tests/unit/index.js +5 -4
  27. package/build/tests/unit/mocks/mockAdapter.d.ts +3 -3
  28. package/build/tests/unit/mocks/mockAdapter.js +195 -162
  29. package/build/tests/unit/mocks/mockAdapterCore.d.ts +4 -9
  30. package/build/tests/unit/mocks/mockAdapterCore.js +23 -14
  31. package/build/tests/unit/mocks/mockDatabase.d.ts +13 -12
  32. package/build/tests/unit/mocks/mockDatabase.js +40 -45
  33. package/build/tests/unit/mocks/mockLogger.d.ts +1 -1
  34. package/build/tests/unit/mocks/mockLogger.js +1 -1
  35. package/build/tests/unit/mocks/tools.d.ts +2 -2
  36. package/build/tests/unit/mocks/tools.js +14 -11
  37. package/package.json +15 -22
@@ -8,80 +8,82 @@ const tools_1 = require("./tools");
8
8
  // Define here which methods were implemented manually, so we can hook them up with a real stub
9
9
  // The value describes if and how the async version of the callback is constructed
10
10
  const implementedMethods = {
11
- getObject: "normal",
12
- setObject: "normal",
13
- setObjectNotExists: "normal",
14
- extendObject: "normal",
15
- getForeignObject: "normal",
16
- getForeignObjects: "normal",
17
- setForeignObject: "normal",
18
- setForeignObjectNotExists: "normal",
19
- extendForeignObject: "normal",
20
- getState: "normal",
21
- getStates: "normal",
22
- setState: "normal",
23
- setStateChanged: "normal",
24
- delState: "normal",
25
- getForeignState: "normal",
26
- setForeignState: "normal",
27
- setForeignStateChanged: "normal",
28
- subscribeStates: "normal",
29
- subscribeForeignStates: "normal",
30
- subscribeObjects: "normal",
31
- subscribeForeignObjects: "normal",
32
- getAdapterObjects: "no error",
33
- getObjectView: "normal",
34
- getObjectList: "normal",
35
- on: "none",
36
- removeListener: "none",
37
- removeAllListeners: "none",
38
- terminate: "none",
39
- getPort: "no error",
40
- checkPassword: "no error",
41
- setPassword: "normal",
42
- checkGroup: "no error",
43
- calculatePermissions: "no error",
44
- getCertificates: "normal",
45
- sendTo: "no error",
46
- sendToHost: "no error",
47
- getHistory: "normal",
11
+ getObject: 'normal',
12
+ setObject: 'normal',
13
+ setObjectNotExists: 'normal',
14
+ extendObject: 'normal',
15
+ getForeignObject: 'normal',
16
+ getForeignObjects: 'normal',
17
+ setForeignObject: 'normal',
18
+ setForeignObjectNotExists: 'normal',
19
+ extendForeignObject: 'normal',
20
+ getState: 'normal',
21
+ getStates: 'normal',
22
+ setState: 'normal',
23
+ setStateChanged: 'normal',
24
+ delState: 'normal',
25
+ getForeignState: 'normal',
26
+ setForeignState: 'normal',
27
+ setForeignStateChanged: 'normal',
28
+ subscribeStates: 'normal',
29
+ subscribeForeignStates: 'normal',
30
+ subscribeObjects: 'normal',
31
+ subscribeForeignObjects: 'normal',
32
+ getAdapterObjects: 'no error',
33
+ getObjectView: 'normal',
34
+ getObjectList: 'normal',
35
+ on: 'none',
36
+ removeListener: 'none',
37
+ removeAllListeners: 'none',
38
+ terminate: 'none',
39
+ getPort: 'no error',
40
+ checkPassword: 'no error',
41
+ setPassword: 'normal',
42
+ checkGroup: 'no error',
43
+ calculatePermissions: 'no error',
44
+ getCertificates: 'normal',
45
+ sendTo: 'no error',
46
+ sendToHost: 'no error',
47
+ getHistory: 'normal',
48
48
  // @ts-expect-error This method was deprecated
49
- setBinaryState: "normal",
50
- getBinaryState: "normal",
51
- getEnum: "normal",
52
- getEnums: "normal",
53
- addChannelToEnum: "normal",
54
- deleteChannelFromEnum: "normal",
55
- addStateToEnum: "normal",
56
- deleteStateFromEnum: "normal",
57
- createDevice: "normal",
58
- deleteDevice: "normal",
59
- createChannel: "normal",
60
- deleteChannel: "normal",
61
- createState: "normal",
62
- deleteState: "normal",
63
- getDevices: "normal",
64
- getChannelsOf: "normal",
65
- getStatesOf: "normal",
66
- readDir: "normal",
67
- mkDir: "normal",
68
- readFile: "normal",
69
- writeFile: "normal",
70
- delFile: "normal",
71
- unlink: "normal",
72
- rename: "normal",
73
- chmodFile: "normal",
49
+ setBinaryState: 'normal',
50
+ getBinaryState: 'normal',
51
+ getEnum: 'normal',
52
+ getEnums: 'normal',
53
+ addChannelToEnum: 'normal',
54
+ deleteChannelFromEnum: 'normal',
55
+ addStateToEnum: 'normal',
56
+ deleteStateFromEnum: 'normal',
57
+ createDevice: 'normal',
58
+ deleteDevice: 'normal',
59
+ createChannel: 'normal',
60
+ deleteChannel: 'normal',
61
+ createState: 'normal',
62
+ deleteState: 'normal',
63
+ getDevices: 'normal',
64
+ getChannelsOf: 'normal',
65
+ getStatesOf: 'normal',
66
+ readDir: 'normal',
67
+ mkDir: 'normal',
68
+ readFile: 'normal',
69
+ writeFile: 'normal',
70
+ delFile: 'normal',
71
+ unlink: 'normal',
72
+ rename: 'normal',
73
+ chmodFile: 'normal',
74
74
  };
75
75
  function getCallback(...args) {
76
76
  const lastArg = args[args.length - 1];
77
- if (typeof lastArg === "function")
77
+ if (typeof lastArg === 'function') {
78
78
  return lastArg;
79
+ }
79
80
  }
80
81
  /** Stub implementation which can be promisified */
81
82
  const asyncEnabledStub = ((...args) => {
82
83
  const callback = getCallback(...args);
83
- if (typeof callback === "function")
84
+ if (typeof callback === 'function') {
84
85
  callback();
86
+ }
85
87
  });
86
88
  /**
87
89
  * Creates an adapter mock that is connected to a given database mock
@@ -90,18 +92,18 @@ function createAdapterMock(db, options = {}) {
90
92
  // In order to support ES6-style adapters with inheritance, we need to work on the instance directly
91
93
  const ret = this || {};
92
94
  Object.assign(ret, {
93
- name: options.name || "test",
94
- host: "testhost",
95
+ name: options.name || 'test',
96
+ host: 'testhost',
95
97
  instance: options.instance || 0,
96
- namespace: `${options.name || "test"}.${options.instance || 0}`,
98
+ namespace: `${options.name || 'test'}.${options.instance || 0}`,
97
99
  config: options.config || {},
98
100
  common: {},
99
101
  systemConfig: null,
100
- adapterDir: "",
102
+ adapterDir: '',
101
103
  ioPack: {},
102
104
  pack: {},
103
105
  log: (0, mockLogger_1.createLoggerMock)(),
104
- version: "any",
106
+ version: 'any',
105
107
  connected: true,
106
108
  getPort: asyncEnabledStub,
107
109
  stop: (0, sinon_1.stub)(),
@@ -114,28 +116,34 @@ function createAdapterMock(db, options = {}) {
114
116
  sendToHost: asyncEnabledStub,
115
117
  idToDCS: (0, sinon_1.stub)(),
116
118
  getObject: ((id, ...args) => {
117
- if (!id.startsWith(ret.namespace))
118
- id = ret.namespace + "." + id;
119
+ if (!id.startsWith(ret.namespace)) {
120
+ id = `${ret.namespace}.${id}`;
121
+ }
119
122
  const callback = getCallback(...args);
120
- if (callback)
123
+ if (callback) {
121
124
  callback(null, db.getObject(id));
125
+ }
122
126
  }),
123
127
  setObject: ((id, obj, ...args) => {
124
- if (!id.startsWith(ret.namespace))
125
- id = ret.namespace + "." + id;
128
+ if (!id.startsWith(ret.namespace)) {
129
+ id = `${ret.namespace}.${id}`;
130
+ }
126
131
  obj._id = id;
127
132
  db.publishObject(obj);
128
133
  const callback = getCallback(...args);
129
- if (callback)
134
+ if (callback) {
130
135
  callback(null, { id });
136
+ }
131
137
  }),
132
138
  setObjectNotExists: ((id, obj, ...args) => {
133
- if (!id.startsWith(ret.namespace))
134
- id = ret.namespace + "." + id;
139
+ if (!id.startsWith(ret.namespace)) {
140
+ id = `${ret.namespace}.${id}`;
141
+ }
135
142
  const callback = getCallback(...args);
136
143
  if (db.hasObject(id)) {
137
- if (callback)
144
+ if (callback) {
138
145
  callback(null, { id });
146
+ }
139
147
  }
140
148
  else {
141
149
  ret.setObject(id, obj, callback);
@@ -145,19 +153,21 @@ function createAdapterMock(db, options = {}) {
145
153
  callback(db.getObjects(`${ret.namespace}.*`));
146
154
  }),
147
155
  getObjectView: ((design, search, { startkey, endkey }, ...args) => {
148
- if (design !== "system") {
149
- throw new Error("If you want to use a custom design for getObjectView, you need to mock it yourself!");
156
+ if (design !== 'system') {
157
+ throw new Error('If you want to use a custom design for getObjectView, you need to mock it yourself!');
150
158
  }
151
159
  const callback = getCallback(...args);
152
- if (typeof callback === "function") {
153
- let objects = (0, objects_1.values)(db.getObjects("*"));
154
- objects = objects.filter((obj) => obj.type === search);
155
- if (startkey)
156
- objects = objects.filter((obj) => obj._id >= startkey);
157
- if (endkey)
158
- objects = objects.filter((obj) => obj._id <= endkey);
160
+ if (typeof callback === 'function') {
161
+ let objects = Object.values(db.getObjects('*'));
162
+ objects = objects.filter(obj => obj.type === search);
163
+ if (startkey) {
164
+ objects = objects.filter(obj => obj._id >= startkey);
165
+ }
166
+ if (endkey) {
167
+ objects = objects.filter(obj => obj._id <= endkey);
168
+ }
159
169
  callback(null, {
160
- rows: objects.map((obj) => ({
170
+ rows: objects.map(obj => ({
161
171
  id: obj._id,
162
172
  value: obj,
163
173
  })),
@@ -166,16 +176,19 @@ function createAdapterMock(db, options = {}) {
166
176
  }),
167
177
  getObjectList: (({ startkey, endkey, include_docs, }, ...args) => {
168
178
  const callback = getCallback(...args);
169
- if (typeof callback === "function") {
170
- let objects = (0, objects_1.values)(db.getObjects("*"));
171
- if (startkey)
172
- objects = objects.filter((obj) => obj._id >= startkey);
173
- if (endkey)
174
- objects = objects.filter((obj) => obj._id <= endkey);
175
- if (!include_docs)
176
- objects = objects.filter((obj) => !obj._id.startsWith("_"));
179
+ if (typeof callback === 'function') {
180
+ let objects = Object.values(db.getObjects('*'));
181
+ if (startkey) {
182
+ objects = objects.filter(obj => obj._id >= startkey);
183
+ }
184
+ if (endkey) {
185
+ objects = objects.filter(obj => obj._id <= endkey);
186
+ }
187
+ if (!include_docs) {
188
+ objects = objects.filter(obj => !obj._id.startsWith('_'));
189
+ }
177
190
  callback(null, {
178
- rows: objects.map((obj) => ({
191
+ rows: objects.map(obj => ({
179
192
  id: obj._id,
180
193
  value: obj,
181
194
  doc: obj,
@@ -184,49 +197,55 @@ function createAdapterMock(db, options = {}) {
184
197
  }
185
198
  }),
186
199
  extendObject: ((id, obj, ...args) => {
187
- if (!id.startsWith(ret.namespace))
188
- id = ret.namespace + "." + id;
200
+ if (!id.startsWith(ret.namespace)) {
201
+ id = `${ret.namespace}.${id}`;
202
+ }
189
203
  const existing = db.getObject(id) || {};
190
204
  const target = (0, objects_1.extend)({}, existing, obj);
191
205
  target._id = id;
192
206
  db.publishObject(target);
193
207
  const callback = getCallback(...args);
194
- if (callback)
208
+ if (callback) {
195
209
  callback(null, { id: target._id, value: target }, id);
210
+ }
196
211
  }),
197
212
  delObject: ((id, ...args) => {
198
- if (!id.startsWith(ret.namespace))
199
- id = ret.namespace + "." + id;
213
+ if (!id.startsWith(ret.namespace)) {
214
+ id = `${ret.namespace}.${id}`;
215
+ }
200
216
  db.deleteObject(id);
201
217
  const callback = getCallback(...args);
202
- if (callback)
218
+ if (callback) {
203
219
  callback(undefined);
220
+ }
204
221
  }),
205
222
  getForeignObject: ((id, ...args) => {
206
223
  const callback = getCallback(...args);
207
- if (callback)
224
+ if (callback) {
208
225
  callback(null, db.getObject(id));
226
+ }
209
227
  }),
210
228
  getForeignObjects: ((pattern, ...args) => {
211
- const type = typeof args[0] === "string"
212
- ? args[0]
213
- : undefined;
229
+ const type = typeof args[0] === 'string' ? args[0] : undefined;
214
230
  const callback = getCallback(...args);
215
- if (callback)
231
+ if (callback) {
216
232
  callback(null, db.getObjects(pattern, type));
233
+ }
217
234
  }),
218
235
  setForeignObject: ((id, obj, ...args) => {
219
236
  obj._id = id;
220
237
  db.publishObject(obj);
221
238
  const callback = getCallback(...args);
222
- if (callback)
239
+ if (callback) {
223
240
  callback(null, { id });
241
+ }
224
242
  }),
225
243
  setForeignObjectNotExists: ((id, obj, ...args) => {
226
244
  const callback = getCallback(...args);
227
245
  if (db.hasObject(id)) {
228
- if (callback)
246
+ if (callback) {
229
247
  callback(null, { id });
248
+ }
230
249
  }
231
250
  else {
232
251
  ret.setObject(id, obj, callback);
@@ -238,117 +257,134 @@ function createAdapterMock(db, options = {}) {
238
257
  target._id = id;
239
258
  db.publishObject(target);
240
259
  const callback = getCallback(...args);
241
- if (callback)
260
+ if (callback) {
242
261
  callback(null, { id: target._id, value: target }, id);
262
+ }
243
263
  }),
244
264
  findForeignObject: (0, sinon_1.stub)(),
245
265
  delForeignObject: ((id, ...args) => {
246
266
  db.deleteObject(id);
247
267
  const callback = getCallback(...args);
248
- if (callback)
268
+ if (callback) {
249
269
  callback(undefined);
270
+ }
250
271
  }),
251
272
  setState: ((id, state, ...args) => {
252
273
  const callback = getCallback(...args);
253
- if (!id.startsWith(ret.namespace))
254
- id = ret.namespace + "." + id;
274
+ if (!id.startsWith(ret.namespace)) {
275
+ id = `${ret.namespace}.${id}`;
276
+ }
255
277
  let ack;
256
- if (state != null && typeof state === "object") {
278
+ if (state != null && typeof state === 'object') {
257
279
  ack = !!state.ack;
258
280
  state = state.val;
259
281
  }
260
282
  else {
261
- ack = typeof args[0] === "boolean" ? args[0] : false;
283
+ ack = typeof args[0] === 'boolean' ? args[0] : false;
262
284
  }
263
285
  db.publishState(id, { val: state, ack });
264
- if (callback)
286
+ if (callback) {
265
287
  callback(null, id);
288
+ }
266
289
  }),
267
290
  setStateChanged: ((id, state, ...args) => {
268
291
  const callback = getCallback(...args);
269
292
  let ack;
270
- if (state != null && typeof state === "object") {
293
+ if (state != null && typeof state === 'object') {
271
294
  ack = !!state.ack;
272
295
  state = state.val;
273
296
  }
274
297
  else {
275
- ack = typeof args[0] === "boolean" ? args[0] : false;
298
+ ack = typeof args[0] === 'boolean' ? args[0] : false;
299
+ }
300
+ if (!id.startsWith(ret.namespace)) {
301
+ id = `${ret.namespace}.${id}`;
276
302
  }
277
- if (!id.startsWith(ret.namespace))
278
- id = ret.namespace + "." + id;
279
303
  if (!db.hasState(id) || db.getState(id).val !== state) {
280
304
  db.publishState(id, { val: state, ack });
281
305
  }
282
- if (callback)
306
+ if (callback) {
283
307
  callback(null, id);
308
+ }
284
309
  }),
285
310
  setForeignState: ((id, state, ...args) => {
286
311
  const callback = getCallback(...args);
287
312
  let ack;
288
- if (state != null && typeof state === "object") {
313
+ if (state != null && typeof state === 'object') {
289
314
  ack = !!state.ack;
290
315
  state = state.val;
291
316
  }
292
317
  else {
293
- ack = typeof args[0] === "boolean" ? args[0] : false;
318
+ ack = typeof args[0] === 'boolean' ? args[0] : false;
294
319
  }
295
320
  db.publishState(id, { val: state, ack });
296
- if (callback)
321
+ if (callback) {
297
322
  callback(null, id);
323
+ }
298
324
  }),
299
325
  setForeignStateChanged: ((id, state, ...args) => {
300
326
  const callback = getCallback(...args);
301
327
  let ack;
302
- if (state != null && typeof state === "object") {
328
+ if (state != null && typeof state === 'object') {
303
329
  ack = !!state.ack;
304
330
  state = state.val;
305
331
  }
306
332
  else {
307
- ack = typeof args[0] === "boolean" ? args[0] : false;
333
+ ack = typeof args[0] === 'boolean' ? args[0] : false;
308
334
  }
309
335
  if (!db.hasState(id) || db.getState(id).val !== state) {
310
336
  db.publishState(id, { val: state, ack });
311
337
  }
312
- if (callback)
338
+ if (callback) {
313
339
  callback(null, id);
340
+ }
314
341
  }),
315
342
  getState: ((id, ...args) => {
316
- if (!id.startsWith(ret.namespace))
317
- id = ret.namespace + "." + id;
343
+ if (!id.startsWith(ret.namespace)) {
344
+ id = `${ret.namespace}.${id}`;
345
+ }
318
346
  const callback = getCallback(...args);
319
- if (callback)
347
+ if (callback) {
320
348
  callback(null, db.getState(id));
349
+ }
321
350
  }),
322
351
  getForeignState: ((id, ...args) => {
323
352
  const callback = getCallback(...args);
324
- if (callback)
353
+ if (callback) {
325
354
  callback(null, db.getState(id));
355
+ }
326
356
  }),
327
357
  getStates: ((pattern, ...args) => {
328
- if (!pattern.startsWith(ret.namespace))
329
- pattern = ret.namespace + "." + pattern;
358
+ if (!pattern.startsWith(ret.namespace)) {
359
+ pattern = `${ret.namespace}.${pattern}`;
360
+ }
330
361
  const callback = getCallback(...args);
331
- if (callback)
362
+ if (callback) {
332
363
  callback(null, db.getStates(pattern));
364
+ }
333
365
  }),
334
366
  getForeignStates: ((pattern, ...args) => {
335
367
  const callback = getCallback(...args);
336
- if (callback)
368
+ if (callback) {
337
369
  callback(null, db.getStates(pattern));
370
+ }
338
371
  }),
339
372
  delState: ((id, ...args) => {
340
- if (!id.startsWith(ret.namespace))
341
- id = ret.namespace + "." + id;
373
+ if (!id.startsWith(ret.namespace)) {
374
+ id = `${ret.namespace}.${id}`;
375
+ }
342
376
  db.deleteState(id);
343
377
  const callback = getCallback(...args);
344
- if (callback)
378
+ if (callback) {
345
379
  callback(undefined);
380
+ }
346
381
  }),
347
382
  delForeignState: ((id, ...args) => {
348
383
  db.deleteState(id);
349
384
  const callback = getCallback(...args);
350
- if (callback)
385
+ if (callback) {
351
386
  callback(undefined);
387
+ }
352
388
  }),
353
389
  getHistory: asyncEnabledStub,
354
390
  setBinaryState: asyncEnabledStub,
@@ -388,16 +424,16 @@ function createAdapterMock(db, options = {}) {
388
424
  formatValue: (0, sinon_1.stub)(),
389
425
  formatDate: (0, sinon_1.stub)(),
390
426
  terminate: ((reason, exitCode) => {
391
- if (typeof reason === "number") {
427
+ if (typeof reason === 'number') {
392
428
  // Only the exit code was passed
393
429
  exitCode = reason;
394
430
  reason = undefined;
395
431
  }
396
- const errorMessage = `Adapter.terminate was called${typeof exitCode === "number" ? ` (exit code ${exitCode})` : ""}: ${reason ? reason : "Without reason"}`;
432
+ const errorMessage = `Adapter.terminate was called${typeof exitCode === 'number' ? ` (exit code ${exitCode})` : ''}: ${reason ? reason : 'Without reason'}`;
397
433
  // Terminates execution by
398
434
  const err = new Error(errorMessage);
399
435
  // @ts-expect-error I'm too lazy to add terminateReason to the error type
400
- err.terminateReason = reason || "no reason given!";
436
+ err.terminateReason = reason || 'no reason given!';
401
437
  throw err;
402
438
  }),
403
439
  supportsFeature: (0, sinon_1.stub)(),
@@ -407,19 +443,19 @@ function createAdapterMock(db, options = {}) {
407
443
  on: ((event, handler) => {
408
444
  // Remember the event handlers so we can call them on demand
409
445
  switch (event) {
410
- case "ready":
446
+ case 'ready':
411
447
  ret.readyHandler = handler;
412
448
  break;
413
- case "message":
449
+ case 'message':
414
450
  ret.messageHandler = handler;
415
451
  break;
416
- case "objectChange":
452
+ case 'objectChange':
417
453
  ret.objectChangeHandler = handler;
418
454
  break;
419
- case "stateChange":
455
+ case 'stateChange':
420
456
  ret.stateChangeHandler = handler;
421
457
  break;
422
- case "unload":
458
+ case 'unload':
423
459
  ret.unloadHandler = handler;
424
460
  break;
425
461
  }
@@ -428,38 +464,38 @@ function createAdapterMock(db, options = {}) {
428
464
  removeListener: ((event, _listener) => {
429
465
  // TODO This is not entirely correct
430
466
  switch (event) {
431
- case "ready":
467
+ case 'ready':
432
468
  ret.readyHandler = undefined;
433
469
  break;
434
- case "message":
470
+ case 'message':
435
471
  ret.messageHandler = undefined;
436
472
  break;
437
- case "objectChange":
473
+ case 'objectChange':
438
474
  ret.objectChangeHandler = undefined;
439
475
  break;
440
- case "stateChange":
476
+ case 'stateChange':
441
477
  ret.stateChangeHandler = undefined;
442
478
  break;
443
- case "unload":
479
+ case 'unload':
444
480
  ret.unloadHandler = undefined;
445
481
  break;
446
482
  }
447
483
  return ret;
448
484
  }),
449
485
  removeAllListeners: ((event) => {
450
- if (!event || event === "ready") {
486
+ if (!event || event === 'ready') {
451
487
  ret.readyHandler = undefined;
452
488
  }
453
- if (!event || event === "message") {
489
+ if (!event || event === 'message') {
454
490
  ret.messageHandler = undefined;
455
491
  }
456
- if (!event || event === "objectChange") {
492
+ if (!event || event === 'objectChange') {
457
493
  ret.objectChangeHandler = undefined;
458
494
  }
459
- if (!event || event === "stateChange") {
495
+ if (!event || event === 'stateChange') {
460
496
  ret.stateChangeHandler = undefined;
461
497
  }
462
- if (!event || event === "unload") {
498
+ if (!event || event === 'unload') {
463
499
  ret.unloadHandler = undefined;
464
500
  }
465
501
  return ret;
@@ -480,10 +516,7 @@ function createAdapterMock(db, options = {}) {
480
516
  ret.resetMockBehavior();
481
517
  },
482
518
  });
483
- (0, tools_1.stubAndPromisifyImplementedMethods)(ret, implementedMethods, [
484
- "getObjectView",
485
- "getObjectList",
486
- ]);
519
+ (0, tools_1.stubAndPromisifyImplementedMethods)(ret, implementedMethods, ['getObjectView', 'getObjectList']);
487
520
  // Access the options object directly, so we can react to later changes
488
521
  Object.defineProperties(ret, {
489
522
  readyHandler: {
@@ -1,9 +1,5 @@
1
- import { MockAdapter } from "./mockAdapter";
2
- import type { MockDatabase } from "./mockDatabase";
3
- interface MockAdapterConstructor {
4
- new (nameOrOptions: string | ioBroker.AdapterOptions): MockAdapter;
5
- (nameOrOptions: string | ioBroker.AdapterOptions): MockAdapter;
6
- }
1
+ import { type MockAdapter } from './mockAdapter';
2
+ import type { MockDatabase } from './mockDatabase';
7
3
  export interface MockAdapterCoreOptions {
8
4
  onAdapterCreated?: (adapter: MockAdapter) => void;
9
5
  adapterDir?: string;
@@ -11,9 +7,8 @@ export interface MockAdapterCoreOptions {
11
7
  export declare function mockAdapterCore(database: MockDatabase, options?: MockAdapterCoreOptions): {
12
8
  controllerDir: string;
13
9
  getConfig: () => Record<string, any>;
14
- Adapter: MockAdapterConstructor;
15
- adapter: MockAdapterConstructor;
10
+ Adapter: (this: MockAdapter | void, nameOrOptions: string | ioBroker.AdapterOptions) => MockAdapter;
11
+ adapter: (this: MockAdapter | void, nameOrOptions: string | ioBroker.AdapterOptions) => MockAdapter;
16
12
  getAbsoluteDefaultDataDir: () => string;
17
13
  getAbsoluteInstanceDataDir: (adapterObject: MockAdapter) => string;
18
14
  };
19
- export {};