@matterbridge/test-utils 3.10.7-dev-20260823-f911eb8
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/buntest/export.d.ts +25 -0
- package/dist/buntest/export.d.ts.map +1 -0
- package/dist/buntest/export.js +26 -0
- package/dist/buntest/export.js.map +1 -0
- package/dist/buntest/matterTest.d.ts +351 -0
- package/dist/buntest/matterTest.d.ts.map +1 -0
- package/dist/buntest/matterTest.js +722 -0
- package/dist/buntest/matterTest.js.map +1 -0
- package/dist/buntest/setupTest.d.ts +84 -0
- package/dist/buntest/setupTest.d.ts.map +1 -0
- package/dist/buntest/setupTest.js +153 -0
- package/dist/buntest/setupTest.js.map +1 -0
- package/dist/export.d.ts +25 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +25 -0
- package/dist/export.js.map +1 -0
- package/dist/flushAsync.d.ts +36 -0
- package/dist/flushAsync.d.ts.map +1 -0
- package/dist/flushAsync.js +43 -0
- package/dist/flushAsync.js.map +1 -0
- package/dist/jest/export.d.ts +25 -0
- package/dist/jest/export.d.ts.map +1 -0
- package/dist/jest/export.js +26 -0
- package/dist/jest/export.js.map +1 -0
- package/dist/jest/matterTest.d.ts +351 -0
- package/dist/jest/matterTest.d.ts.map +1 -0
- package/dist/jest/matterTest.js +722 -0
- package/dist/jest/matterTest.js.map +1 -0
- package/dist/jest/setupTest.d.ts +83 -0
- package/dist/jest/setupTest.d.ts.map +1 -0
- package/dist/jest/setupTest.js +154 -0
- package/dist/jest/setupTest.js.map +1 -0
- package/dist/logKeepAlives.d.ts +32 -0
- package/dist/logKeepAlives.d.ts.map +1 -0
- package/dist/logKeepAlives.js +69 -0
- package/dist/logKeepAlives.js.map +1 -0
- package/dist/matter/export.d.ts +24 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +25 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/matterRequest.d.ts +257 -0
- package/dist/matter/matterRequest.d.ts.map +1 -0
- package/dist/matter/matterRequest.js +455 -0
- package/dist/matter/matterRequest.js.map +1 -0
- package/dist/vitest/export.d.ts +25 -0
- package/dist/vitest/export.d.ts.map +1 -0
- package/dist/vitest/export.js +26 -0
- package/dist/vitest/export.js.map +1 -0
- package/dist/vitest/matterTest.d.ts +351 -0
- package/dist/vitest/matterTest.d.ts.map +1 -0
- package/dist/vitest/matterTest.js +723 -0
- package/dist/vitest/matterTest.js.map +1 -0
- package/dist/vitest/setupTest.d.ts +62 -0
- package/dist/vitest/setupTest.d.ts.map +1 -0
- package/dist/vitest/setupTest.js +129 -0
- package/dist/vitest/setupTest.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file packages/test-utils/src/buntest.ts
|
|
3
|
+
* @description Re-export the Bun test utility API used in the repo's buntest directory.
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2026-08-23
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
export * from './matterTest.js';
|
|
24
|
+
export * from './setupTest.js';
|
|
25
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/buntest/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file packages/test-utils/src/buntest.ts
|
|
3
|
+
* @description Re-export the Bun test utility API used in the repo's buntest directory.
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2026-08-23
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
/* oxlint-disable oxc/no-barrel-file */
|
|
24
|
+
export * from './matterTest.js';
|
|
25
|
+
export * from './setupTest.js';
|
|
26
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/buntest/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,uCAAuC;AAEvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description This file contains the Bun Matter Test Environment.
|
|
3
|
+
* @file buntest/bunMatterTest.ts
|
|
4
|
+
* @author Luca Liguori
|
|
5
|
+
* @created 2026-04-19
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license Apache-2.0
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
import '@matter/nodejs';
|
|
24
|
+
import { Environment } from '@matter/general';
|
|
25
|
+
import { Endpoint, ServerNode } from '@matter/node';
|
|
26
|
+
import { AggregatorEndpoint } from '@matter/node/endpoints';
|
|
27
|
+
import { DeviceTypeId } from '@matter/types/datatype';
|
|
28
|
+
import { type PlatformMatterbridge } from '@matterbridge/types';
|
|
29
|
+
export declare let environment: Environment;
|
|
30
|
+
export declare let server: ServerNode;
|
|
31
|
+
export declare let aggregator: Endpoint<AggregatorEndpoint>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a matter test environment for testing:
|
|
34
|
+
* - it will remove any existing home directory
|
|
35
|
+
* - setup the matter environment with name, debug logging and ANSI format
|
|
36
|
+
*
|
|
37
|
+
* @returns {Environment} - The default matter environment.
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const NAME = 'BaseTest';
|
|
41
|
+
* const MATTER_PORT = 8000;
|
|
42
|
+
* const MATTER_CREATE_ONLY = true;
|
|
43
|
+
*
|
|
44
|
+
* // Setup the test environment
|
|
45
|
+
* await setupTest(NAME, false);
|
|
46
|
+
*
|
|
47
|
+
* // Setup the Matter test environment
|
|
48
|
+
* await createTestEnvironment();
|
|
49
|
+
*
|
|
50
|
+
* // Create the server node and aggregator
|
|
51
|
+
* await createServerNode(MATTER_PORT);
|
|
52
|
+
*
|
|
53
|
+
* // Start the server node if not in create-only mode
|
|
54
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
55
|
+
*
|
|
56
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
57
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
58
|
+
* else await stopServerNode();
|
|
59
|
+
*
|
|
60
|
+
* // Destroy the Matter test environment
|
|
61
|
+
* await destroyTestEnvironment();
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createTestEnvironment(): Promise<Environment>;
|
|
65
|
+
/**
|
|
66
|
+
* Destroy the matter test environment
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<void>} A promise that resolves when the test environment is destroyed.
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const NAME = 'BaseTest';
|
|
72
|
+
* const MATTER_PORT = 8000;
|
|
73
|
+
* const MATTER_CREATE_ONLY = true;
|
|
74
|
+
*
|
|
75
|
+
* // Setup the test environment
|
|
76
|
+
* await setupTest(NAME, false);
|
|
77
|
+
*
|
|
78
|
+
* // Setup the Matter test environment
|
|
79
|
+
* await createTestEnvironment();
|
|
80
|
+
*
|
|
81
|
+
* // Create the server node and aggregator
|
|
82
|
+
* await createServerNode(MATTER_PORT);
|
|
83
|
+
*
|
|
84
|
+
* // Start the server node if not in create-only mode
|
|
85
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
86
|
+
*
|
|
87
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
88
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
89
|
+
* else await stopServerNode();
|
|
90
|
+
*
|
|
91
|
+
* // Destroy the Matter test environment
|
|
92
|
+
* await destroyTestEnvironment();
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function destroyTestEnvironment(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Get a mocked PlatformMatterbridge.
|
|
98
|
+
*
|
|
99
|
+
* @returns {PlatformMatterbridge} An object representing the mocked PlatformMatterbridge.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getMatterbridge(): PlatformMatterbridge;
|
|
102
|
+
/**
|
|
103
|
+
* Add a bridged endpoint
|
|
104
|
+
*
|
|
105
|
+
* @param {string} pluginName The name of the plugin.
|
|
106
|
+
* @param {Endpoint} device The device to add.
|
|
107
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the endpoint was added successfully, or rejects with an error if the operation failed.
|
|
108
|
+
*/
|
|
109
|
+
export declare const addBridgedEndpoint: (pluginName: string, device: Endpoint) => Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Remove a bridged endpoint
|
|
112
|
+
*
|
|
113
|
+
* @param {string} pluginName The name of the plugin.
|
|
114
|
+
* @param {Endpoint} device The device to remove.
|
|
115
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the endpoint was removed successfully, or rejects with an error if the operation failed.
|
|
116
|
+
*/
|
|
117
|
+
export declare const removeBridgedEndpoint: (pluginName: string, device: Endpoint) => Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Remove all bridged endpoints
|
|
120
|
+
*
|
|
121
|
+
* @param {string} _pluginName The name of the plugin.
|
|
122
|
+
* @param {number} _delay The delay before removing all endpoints.
|
|
123
|
+
* @returns {Promise<boolean>} A promise that resolves to true if all endpoints were removed successfully, or rejects with an error if the operation failed.
|
|
124
|
+
*/
|
|
125
|
+
export declare const removeAllBridgedEndpoints: (_pluginName: string, _delay?: number) => Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Add a virtual endpoint
|
|
128
|
+
*
|
|
129
|
+
* @param {string} pluginName The name of the plugin.
|
|
130
|
+
* @param {string} name The name of the virtual endpoint.
|
|
131
|
+
* @param {'light' | 'outlet' | 'switch' | 'mounted_switch'} type The type of the virtual endpoint.
|
|
132
|
+
* @param {() => Promise<void>} callback The callback to execute when the virtual endpoint is triggered.
|
|
133
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the virtual endpoint was added successfully, or rejects with an error if the operation failed.
|
|
134
|
+
*/
|
|
135
|
+
export declare const addVirtualEndpoint: (pluginName: string, name: string, type: 'light' | 'outlet' | 'switch' | 'mounted_switch', callback: () => Promise<void>) => Promise<boolean>;
|
|
136
|
+
/**
|
|
137
|
+
* Inject matterbridge platform for testing.
|
|
138
|
+
*
|
|
139
|
+
* @param {object} platform The platform to inject.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* platform = new MatterbridgePlatform(matterbridge, log, config);
|
|
144
|
+
* // Inject in the platform the Matterbridge environment
|
|
145
|
+
* addMatterbridge(platform);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function addMatterbridge(platform: object): void;
|
|
149
|
+
/**
|
|
150
|
+
* Flush (await) the lazy endpoint number persistence mechanism used by matter.js.
|
|
151
|
+
*
|
|
152
|
+
* Background:
|
|
153
|
+
* assignNumber() batches persistence (store.saveNumber + updating __nextNumber__) via an internal promise (#numbersPersisted).
|
|
154
|
+
* Calling endpointStores.close() waits for the current batch only. If new endpoints were added in the same macrotask
|
|
155
|
+
* cycle additional micro/macro turns might be needed to ensure the batch started. We defensively yield macrotasks
|
|
156
|
+
* (setImmediate) and then await close() multiple rounds.
|
|
157
|
+
*
|
|
158
|
+
* @param {ServerNode} targetServer The server whose endpoint numbering persistence should be flushed.
|
|
159
|
+
* @param {number} rounds Number of macrotask + close cycles to run (3 is usually sufficient).
|
|
160
|
+
* @param {number} ticks Number of macrotask (setImmediate) turns to yield after stopping the server to allow asynchronous work to complete before returning (default 1).
|
|
161
|
+
* @param {number} microTurns Number of microtask drains (Promise.resolve chains) to perform after macrotask yielding to allow asynchronous work to complete before returning (default 1).
|
|
162
|
+
* @param {number} pause Duration in ms to wait between cycles (default 10ms) to allow any follow-up work scheduled by close() to run.
|
|
163
|
+
* @returns {Promise<void>} Resolves when pending number persistence batches have completed.
|
|
164
|
+
*/
|
|
165
|
+
export declare function flushAllEndpointNumberPersistence(targetServer: ServerNode, rounds?: number, ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Assert that every endpoint attached to the server has an assigned and (batch-)persisted endpoint number.
|
|
168
|
+
*
|
|
169
|
+
* This waits for any outstanding number persistence batch (endpointStores.close()), then traverses the endpoint
|
|
170
|
+
* graph and asserts:
|
|
171
|
+
* - Root endpoint: number is 0 (allowing undefined to coerce to 0 via nullish coalescing check).
|
|
172
|
+
* - All other endpoints: number > 0.
|
|
173
|
+
*
|
|
174
|
+
* @param {ServerNode} targetServer The server whose endpoint numbers are verified.
|
|
175
|
+
* @returns {Promise<void>} Resolves when assertions complete.
|
|
176
|
+
*/
|
|
177
|
+
export declare function assertAllEndpointNumbersPersisted(targetServer: ServerNode): Promise<number>;
|
|
178
|
+
/**
|
|
179
|
+
* Close the server node stores to flush any pending endpoint number persistence.
|
|
180
|
+
*
|
|
181
|
+
* @param {ServerNode} targetServer The server whose endpoint stores should be closed.
|
|
182
|
+
* @returns {Promise<void>} Resolves when the stores have been closed.
|
|
183
|
+
*/
|
|
184
|
+
export declare function closeServerNodeStores(targetServer?: ServerNode): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Create a matter server node for testing.
|
|
187
|
+
*
|
|
188
|
+
* @param {number} port TCP port to listen on.
|
|
189
|
+
* @param {DeviceTypeId} deviceType Device type identifier for the server node. Defaults to the bridge device type.
|
|
190
|
+
* @param {number} ticks Number of macrotask (setImmediate) turns to yield after starting the server to allow asynchronous work to complete before returning (default 1).
|
|
191
|
+
* @param {number} microTurns Number of microtask drains (Promise.resolve chains) to perform after macrotask yielding to allow asynchronous work to complete before returning (default 1).
|
|
192
|
+
* @param {number} pause Final timer delay in ms to wait after microtask draining to allow any follow-up work scheduled by the server start process to run before returning (default 10ms).
|
|
193
|
+
* @returns {Promise<[ServerNode<ServerNode.RootEndpoint>, Endpoint<AggregatorEndpoint>]>} Resolves to an array containing the created ServerNode and its AggregatorNode.
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const NAME = 'BaseTest';
|
|
197
|
+
* const MATTER_PORT = 8000;
|
|
198
|
+
* const MATTER_CREATE_ONLY = true;
|
|
199
|
+
*
|
|
200
|
+
* // Setup the test environment
|
|
201
|
+
* await setupTest(NAME, false);
|
|
202
|
+
*
|
|
203
|
+
* // Setup the Matter test environment
|
|
204
|
+
* await createTestEnvironment();
|
|
205
|
+
*
|
|
206
|
+
* // Create the server node and aggregator
|
|
207
|
+
* await createServerNode(MATTER_PORT);
|
|
208
|
+
*
|
|
209
|
+
* // Start the server node if not in create-only mode
|
|
210
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
211
|
+
*
|
|
212
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
213
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
214
|
+
* else await stopServerNode();
|
|
215
|
+
*
|
|
216
|
+
* // Destroy the Matter test environment
|
|
217
|
+
* await destroyTestEnvironment();
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare function createServerNode(port: number, deviceType?: DeviceTypeId, ticks?: number, microTurns?: number, pause?: number): Promise<[ServerNode, Endpoint<AggregatorEndpoint>]>;
|
|
221
|
+
/**
|
|
222
|
+
* Start a matter server node for testing.
|
|
223
|
+
*
|
|
224
|
+
* @param {number} ticks Number of macrotask (setImmediate) turns to yield after starting the server to allow asynchronous work to complete before returning (default 1).
|
|
225
|
+
* @param {number} microTurns Number of microtask drains (Promise.resolve chains) to perform after macrotask yielding to allow asynchronous work to complete before returning (default 1).
|
|
226
|
+
* @param {number} pause Final timer delay in ms to wait after microtask draining to allow any follow-up work scheduled by the server start process to run before returning (default 10ms).
|
|
227
|
+
* @returns {Promise<[ServerNode<ServerNode.RootEndpoint>, Endpoint<AggregatorEndpoint>]>} Resolves to an array containing the created ServerNode and its AggregatorNode.
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const NAME = 'BaseTest';
|
|
231
|
+
* const MATTER_PORT = 8000;
|
|
232
|
+
* const MATTER_CREATE_ONLY = true;
|
|
233
|
+
*
|
|
234
|
+
* // Setup the test environment
|
|
235
|
+
* await setupTest(NAME, false);
|
|
236
|
+
*
|
|
237
|
+
* // Setup the Matter test environment
|
|
238
|
+
* await createTestEnvironment();
|
|
239
|
+
*
|
|
240
|
+
* // Create the server node and aggregator
|
|
241
|
+
* await createServerNode(MATTER_PORT);
|
|
242
|
+
*
|
|
243
|
+
* // Start the server node if not in create-only mode
|
|
244
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
245
|
+
*
|
|
246
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
247
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
248
|
+
* else await stopServerNode();
|
|
249
|
+
*
|
|
250
|
+
* // Destroy the Matter test environment
|
|
251
|
+
* await destroyTestEnvironment();
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export declare function startServerNode(ticks?: number, microTurns?: number, pause?: number): Promise<[ServerNode, Endpoint<AggregatorEndpoint>]>;
|
|
255
|
+
/**
|
|
256
|
+
* Stop a matter server node.
|
|
257
|
+
*
|
|
258
|
+
* @param {number} ticks Number of macrotask (setImmediate) turns to yield after stopping the server to allow asynchronous work to complete before returning (default 1).
|
|
259
|
+
* @param {number} microTurns Number of microtask drains (Promise.resolve chains) to perform after macrotask yielding to allow asynchronous work to complete before returning (default 1).
|
|
260
|
+
* @param {number} pause Final timer delay in ms to wait after microtask draining to allow any follow-up work scheduled by the server stop process to run before returning (default 10ms).
|
|
261
|
+
* @returns {Promise<void>} Resolves when the server has stopped.
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const NAME = 'BaseTest';
|
|
265
|
+
* const MATTER_PORT = 8000;
|
|
266
|
+
* const MATTER_CREATE_ONLY = true;
|
|
267
|
+
*
|
|
268
|
+
* // Setup the test environment
|
|
269
|
+
* await setupTest(NAME, false);
|
|
270
|
+
*
|
|
271
|
+
* // Setup the Matter test environment
|
|
272
|
+
* await createTestEnvironment();
|
|
273
|
+
*
|
|
274
|
+
* // Create the server node and aggregator
|
|
275
|
+
* await createServerNode(MATTER_PORT);
|
|
276
|
+
*
|
|
277
|
+
* // Start the server node if not in create-only mode
|
|
278
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
279
|
+
*
|
|
280
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
281
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
282
|
+
* else await stopServerNode();
|
|
283
|
+
*
|
|
284
|
+
* // Destroy the Matter test environment
|
|
285
|
+
* await destroyTestEnvironment();
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export declare function stopServerNode(ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Flush any pending endpoint number persistence.
|
|
291
|
+
*
|
|
292
|
+
* @param {number} ticks Number of macrotask (setImmediate) turns to yield after stopping the server to allow asynchronous work to complete before returning (default 1).
|
|
293
|
+
* @param {number} microTurns Number of microtask drains (Promise.resolve chains) to perform after macrotask yielding to allow asynchronous work to complete before returning (default 1).
|
|
294
|
+
* @param {number} pause Final timer delay in ms to wait after microtask draining to allow any follow-up work scheduled by the server stop process to run before returning (default 10ms).
|
|
295
|
+
* @returns {Promise<void>} Resolves when the server has stopped.
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const NAME = 'BaseTest';
|
|
299
|
+
* const MATTER_PORT = 8000;
|
|
300
|
+
* const MATTER_CREATE_ONLY = true;
|
|
301
|
+
*
|
|
302
|
+
* // Setup the test environment
|
|
303
|
+
* await setupTest(NAME, false);
|
|
304
|
+
*
|
|
305
|
+
* // Setup the Matter test environment
|
|
306
|
+
* await createTestEnvironment();
|
|
307
|
+
*
|
|
308
|
+
* // Create the server node and aggregator
|
|
309
|
+
* await createServerNode(MATTER_PORT);
|
|
310
|
+
*
|
|
311
|
+
* // Start the server node if not in create-only mode
|
|
312
|
+
* if (!MATTER_CREATE_ONLY) await startServerNode();
|
|
313
|
+
*
|
|
314
|
+
* // Stop or flush the server node depending on the create-only mode
|
|
315
|
+
* if (MATTER_CREATE_ONLY) await flushServerNode();
|
|
316
|
+
* else await stopServerNode();
|
|
317
|
+
*
|
|
318
|
+
* // Destroy the Matter test environment
|
|
319
|
+
* await destroyTestEnvironment();
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
export declare function flushServerNode(ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
323
|
+
/**
|
|
324
|
+
* Add a device (endpoint) to a matter server node or an aggregator.
|
|
325
|
+
*
|
|
326
|
+
* @param {ServerNode<ServerNode.RootEndpoint> | Endpoint<AggregatorEndpoint>} owner The server or aggregator to add the device to.
|
|
327
|
+
* @param {Endpoint} device The device to add.
|
|
328
|
+
* @param {number} rounds The number of rounds to perform after addition (default 3).
|
|
329
|
+
* @param {number} pause The pause time in milliseconds after addition (default 10ms).
|
|
330
|
+
* @returns {Promise<void>} Resolves when the device has been added and is ready.
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* expect(await addDevice(aggregator, device)).toBeTruthy();
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
export declare function addDevice(owner: ServerNode | Endpoint<AggregatorEndpoint>, device: Endpoint, rounds?: number, pause?: number): Promise<boolean>;
|
|
337
|
+
/**
|
|
338
|
+
* Delete a device (endpoint) from a matter server node or an aggregator.
|
|
339
|
+
*
|
|
340
|
+
* @param {ServerNode<ServerNode.RootEndpoint> | Endpoint<AggregatorEndpoint>} owner The server or aggregator to remove the device from.
|
|
341
|
+
* @param {Endpoint} device The device to remove.
|
|
342
|
+
* @param {number} rounds The number of rounds to perform after deletion (default 3).
|
|
343
|
+
* @param {number} pause The pause time in milliseconds after deletion (default 10ms).
|
|
344
|
+
* @returns {Promise<void>} Resolves when the device has been removed and is no longer ready.
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* expect(await deleteDevice(aggregator, device)).toBeTruthy();
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
export declare function deleteDevice(owner: ServerNode | Endpoint<AggregatorEndpoint>, device: Endpoint, rounds?: number, pause?: number): Promise<boolean>;
|
|
351
|
+
//# sourceMappingURL=matterTest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matterTest.d.ts","sourceRoot":"","sources":["../../src/buntest/matterTest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,gBAAgB,CAAC;AAMxB,OAAO,EAAE,WAAW,EAAuE,MAAM,iBAAiB,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAKrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAY,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AASpF,eAAO,IAAI,WAAW,EAAE,WAAW,CAAC;AACpC,eAAO,IAAI,MAAM,EAAE,UAAU,CAAC;AAC9B,eAAO,IAAI,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC,CAalE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6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