@matterbridge/vitest-utils 3.9.1-dev-20260614-89d7aeb → 3.9.1-dev-20260614-18d1a2e
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.
|
@@ -10,14 +10,10 @@ export declare let aggregator: Endpoint<AggregatorEndpoint>;
|
|
|
10
10
|
export declare function createTestEnvironment(): Promise<Environment>;
|
|
11
11
|
export declare function destroyTestEnvironment(): Promise<void>;
|
|
12
12
|
export declare function getMatterbridge(): PlatformMatterbridge;
|
|
13
|
-
export declare const addBridgedEndpoint:
|
|
14
|
-
export declare const removeBridgedEndpoint:
|
|
15
|
-
export declare const removeAllBridgedEndpoints:
|
|
16
|
-
export declare const addVirtualEndpoint:
|
|
17
|
-
export declare const addBridgedEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
18
|
-
export declare const removeBridgedEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
19
|
-
export declare const removeAllBridgedEndpointsMatterbridgeSpy: import("vitest").Mock<(pluginName: string, _delay?: number) => Promise<boolean>>;
|
|
20
|
-
export declare const addVirtualEndpointMatterbridgeSpy: import("vitest").Mock<(pluginName: string, name: string, type: 'light' | 'outlet' | 'switch' | 'mounted_switch', callback: () => Promise<void>) => Promise<boolean>>;
|
|
13
|
+
export declare const addBridgedEndpoint: (pluginName: string, device: Endpoint) => Promise<boolean>;
|
|
14
|
+
export declare const removeBridgedEndpoint: (pluginName: string, device: Endpoint) => Promise<boolean>;
|
|
15
|
+
export declare const removeAllBridgedEndpoints: (pluginName: string, _delay?: number) => Promise<boolean>;
|
|
16
|
+
export declare const addVirtualEndpoint: (pluginName: string, name: string, type: "light" | "outlet" | "switch" | "mounted_switch", callback: () => Promise<void>) => Promise<boolean>;
|
|
21
17
|
export declare function addMatterbridge(platform: object): void;
|
|
22
18
|
export declare function flushAllEndpointNumberPersistence(targetServer: ServerNode, rounds?: number, ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
23
19
|
export declare function assertAllEndpointNumbersPersisted(targetServer: ServerNode): Promise<number>;
|
package/dist/vitestMatterTest.js
CHANGED
|
@@ -75,7 +75,7 @@ export function getMatterbridge() {
|
|
|
75
75
|
};
|
|
76
76
|
return matterbridge;
|
|
77
77
|
}
|
|
78
|
-
export const addBridgedEndpoint =
|
|
78
|
+
export const addBridgedEndpoint = async (pluginName, device) => {
|
|
79
79
|
try {
|
|
80
80
|
await aggregator.add(device);
|
|
81
81
|
return Promise.resolve(true);
|
|
@@ -83,8 +83,8 @@ export const addBridgedEndpoint = vi.fn(async (pluginName, device) => {
|
|
|
83
83
|
catch (error) {
|
|
84
84
|
return Promise.reject(error);
|
|
85
85
|
}
|
|
86
|
-
}
|
|
87
|
-
export const removeBridgedEndpoint =
|
|
86
|
+
};
|
|
87
|
+
export const removeBridgedEndpoint = async (pluginName, device) => {
|
|
88
88
|
try {
|
|
89
89
|
await device.delete();
|
|
90
90
|
return Promise.resolve(true);
|
|
@@ -92,8 +92,8 @@ export const removeBridgedEndpoint = vi.fn(async (pluginName, device) => {
|
|
|
92
92
|
catch (error) {
|
|
93
93
|
return Promise.reject(error);
|
|
94
94
|
}
|
|
95
|
-
}
|
|
96
|
-
export const removeAllBridgedEndpoints =
|
|
95
|
+
};
|
|
96
|
+
export const removeAllBridgedEndpoints = async (pluginName, _delay = 0) => {
|
|
97
97
|
try {
|
|
98
98
|
for (const device of aggregator.parts) {
|
|
99
99
|
await device.delete();
|
|
@@ -103,8 +103,8 @@ export const removeAllBridgedEndpoints = vi.fn(async (pluginName, _delay = 0) =>
|
|
|
103
103
|
catch (error) {
|
|
104
104
|
return Promise.reject(error);
|
|
105
105
|
}
|
|
106
|
-
}
|
|
107
|
-
export const addVirtualEndpoint =
|
|
106
|
+
};
|
|
107
|
+
export const addVirtualEndpoint = async (pluginName, name, type, callback) => {
|
|
108
108
|
try {
|
|
109
109
|
const device = new Endpoint(MountedOnOffControlDevice.with(BridgedDeviceBasicInformationServer), {
|
|
110
110
|
id: name.replaceAll(' ', '') + ':' + type,
|
|
@@ -135,11 +135,7 @@ export const addVirtualEndpoint = vi.fn(async (pluginName, name, type, callback)
|
|
|
135
135
|
catch (error) {
|
|
136
136
|
return Promise.reject(error);
|
|
137
137
|
}
|
|
138
|
-
}
|
|
139
|
-
export const addBridgedEndpointMatterbridgeSpy = addBridgedEndpoint;
|
|
140
|
-
export const removeBridgedEndpointMatterbridgeSpy = removeBridgedEndpoint;
|
|
141
|
-
export const removeAllBridgedEndpointsMatterbridgeSpy = removeAllBridgedEndpoints;
|
|
142
|
-
export const addVirtualEndpointMatterbridgeSpy = addVirtualEndpoint;
|
|
138
|
+
};
|
|
143
139
|
export function addMatterbridge(platform) {
|
|
144
140
|
expect(platform).toBeDefined();
|
|
145
141
|
platform.setMatterNode(addBridgedEndpoint, removeBridgedEndpoint, removeAllBridgedEndpoints, addVirtualEndpoint);
|
|
@@ -17,5 +17,5 @@ export declare let consoleErrorSpy: MockInstance<typeof console.error>;
|
|
|
17
17
|
export declare let NAME: string;
|
|
18
18
|
export declare let HOMEDIR: string;
|
|
19
19
|
export declare let log: AnsiLogger;
|
|
20
|
-
export declare function setupTest(name: string, debug?: boolean): Promise<void>;
|
|
20
|
+
export declare function setupTest(name: string, debug?: boolean, argv?: string[], env?: Record<string, string>): Promise<void>;
|
|
21
21
|
export declare function setDebug(debug: boolean): Promise<void>;
|
package/dist/vitestSetupTest.js
CHANGED
|
@@ -18,13 +18,16 @@ export let consoleErrorSpy;
|
|
|
18
18
|
export let NAME;
|
|
19
19
|
export let HOMEDIR;
|
|
20
20
|
export let log;
|
|
21
|
-
export async function setupTest(name, debug = false) {
|
|
21
|
+
export async function setupTest(name, debug = false, argv = [], env = {}) {
|
|
22
22
|
expect(name).toBeDefined();
|
|
23
23
|
expect(typeof name).toBe('string');
|
|
24
24
|
expect(name.length).toBeGreaterThanOrEqual(4);
|
|
25
25
|
NAME = name;
|
|
26
26
|
HOMEDIR = path.join('.cache', 'vitest', name);
|
|
27
|
-
process.argv = ['vitest', name];
|
|
27
|
+
process.argv = ['vitest', name, ...argv];
|
|
28
|
+
for (const [key, value] of Object.entries(env)) {
|
|
29
|
+
process.env[key] = value;
|
|
30
|
+
}
|
|
28
31
|
log = new AnsiLogger({ logName: 'Vitest', logTimestampFormat: 4, logLevel: "info" });
|
|
29
32
|
rmSync(HOMEDIR, { recursive: true, force: true });
|
|
30
33
|
mkdirSync(HOMEDIR, { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/vitest-utils",
|
|
3
|
-
"version": "3.9.1-dev-20260614-
|
|
3
|
+
"version": "3.9.1-dev-20260614-18d1a2e",
|
|
4
4
|
"description": "Matterbridge vitest utility library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"CHANGELOG.md"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@matterbridge/types": "3.9.1-dev-20260614-
|
|
68
|
+
"@matterbridge/types": "3.9.1-dev-20260614-18d1a2e",
|
|
69
69
|
"node-ansi-logger": "3.3.0-dev-20260607-585945a"
|
|
70
70
|
}
|
|
71
71
|
}
|