@mirta/testing 0.0.6 → 0.1.0

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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,3 @@
1
- import { DevicePlugin } from 'mirta';
2
-
3
1
  interface SimulatorInstance {
4
2
  /** Сбрасывает настройки имитатора перед очередным тестом. */
5
3
  reset(): void;
@@ -62,15 +60,12 @@ interface ZigbeeDevice {
62
60
  }
63
61
  declare function defineZigbeeDevice(deviceId: string): ZigbeeDevice;
64
62
 
65
- type ExtractedPlugin<TPlugin> = TPlugin extends (...args: infer P) => infer R ? R : never;
66
-
67
63
  interface CoreSimulator extends SimulatorInstance {
68
64
  get getDevice(): GetDeviceSimulator;
69
65
  get getControl(): GetControlSimulator;
70
66
  get defineRule(): DefineRuleSimulator;
71
67
  get trackMqtt(): TrackMqttSimulator;
72
68
  defineZigbeeDevice(deviceId: string): ZigbeeDevice;
73
- useDevicePlugin<TPlugin extends DevicePlugin>(deviceId: string, plugin: TPlugin): ExtractedPlugin<TPlugin>;
74
69
  }
75
70
  interface CoreSimulatorOptions {
76
71
  /** Параметры имитатора `defineRule`. */
package/dist/index.mjs CHANGED
@@ -22,9 +22,9 @@ function createInstance$2(options) {
22
22
  : variantB;
23
23
  if (!rule)
24
24
  return;
25
- mqttEvent.on((message) => {
26
- if (rule.whenChanged == message.topic)
27
- rule.then(message.value);
25
+ mqttEvent.on(({ topic, value }) => {
26
+ if (rule.whenChanged === topic)
27
+ rule.then(value);
28
28
  });
29
29
  };
30
30
  }
@@ -196,22 +196,6 @@ function defineZigbeeDevice(deviceId) {
196
196
  };
197
197
  }
198
198
 
199
- function useDevicePlugin(deviceId, plugin) {
200
- const track = (controlId, callback) => {
201
- trackMqtt(`/devices/${deviceId}/controls/${controlId}`, ({ value }) => {
202
- callback(value);
203
- });
204
- };
205
- const context = {
206
- device: {
207
- id: deviceId,
208
- isReady: true,
209
- },
210
- track,
211
- };
212
- return plugin(context);
213
- }
214
-
215
199
  function createSimulator(options) {
216
200
  const simulators = {};
217
201
  function reset() {
@@ -229,7 +213,6 @@ function createSimulator(options) {
229
213
  defineRule,
230
214
  trackMqtt,
231
215
  defineZigbeeDevice,
232
- useDevicePlugin,
233
216
  };
234
217
  }
235
218
  let instance;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirta/testing",
3
3
  "description": "A unit-test runner equipped with built-in Wiren Board runtime emulation",
4
- "version": "0.0.6",
4
+ "version": "0.1.0",
5
5
  "license": "Unlicense",
6
6
  "keywords": [
7
7
  "mirta",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "vitest-mock-extended": "^3.1.0",
35
- "mirta": "0.0.6"
35
+ "mirta": "0.1.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"