@matterbridge/jest-utils 3.8.1-dev-20260606-d6bb335 → 3.8.1-dev-20260608-9dc483f
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/jestMatterTest.d.ts +2 -54
- package/dist/jestMatterTest.js +53 -35
- package/package.json +3 -3
package/dist/jestMatterTest.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import '@matter/nodejs';
|
|
2
2
|
import { Environment } from '@matter/general';
|
|
3
3
|
import { Endpoint, ServerNode } from '@matter/node';
|
|
4
|
-
import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
|
|
5
|
-
import { OnOffServer } from '@matter/node/behaviors/on-off';
|
|
6
4
|
import { AggregatorEndpoint } from '@matter/node/endpoints';
|
|
7
5
|
import { DeviceTypeId } from '@matter/types/datatype';
|
|
8
6
|
import { type PlatformMatterbridge } from '@matterbridge/types';
|
|
@@ -11,61 +9,11 @@ export declare let server: ServerNode<ServerNode.RootEndpoint>;
|
|
|
11
9
|
export declare let aggregator: Endpoint<AggregatorEndpoint>;
|
|
12
10
|
export declare function createTestEnvironment(): Promise<Environment>;
|
|
13
11
|
export declare function destroyTestEnvironment(): Promise<void>;
|
|
14
|
-
export declare function getMatterbridge():
|
|
12
|
+
export declare function getMatterbridge(): PlatformMatterbridge;
|
|
15
13
|
export declare const addBridgedEndpointMatterbridgeSpy: import("jest-mock").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
16
14
|
export declare const removeBridgedEndpointMatterbridgeSpy: import("jest-mock").Mock<(pluginName: string, device: Endpoint) => Promise<boolean>>;
|
|
17
15
|
export declare const removeAllBridgedEndpointsMatterbridgeSpy: import("jest-mock").Mock<(pluginName: string, _delay?: number) => Promise<boolean>>;
|
|
18
|
-
export declare const addVirtualEndpointMatterbridgeSpy: import("jest-mock").Mock<(pluginName: string, name: string, type: "light" | "outlet" | "switch" | "mounted_switch", callback: () => Promise<void>) => Promise<
|
|
19
|
-
readonly name: "MountedOnOffControl";
|
|
20
|
-
readonly deviceType: 271;
|
|
21
|
-
readonly deviceRevision: 2;
|
|
22
|
-
readonly requirements: typeof import("@matter/node/devices/mounted-on-off-control").MountedOnOffControlRequirements;
|
|
23
|
-
readonly behaviors: {
|
|
24
|
-
readonly identify: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").IdentifyServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types/clusters/identify").Identify, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").IdentifyServer.Internal, "identify">;
|
|
25
|
-
} & {
|
|
26
|
-
readonly groups: typeof import("@matter/node/behaviors").GroupsServer;
|
|
27
|
-
} & {
|
|
28
|
-
readonly onOff: import("@matter/node").ClusterBehavior.Type<typeof OnOffServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/on-off").OnOff, {
|
|
29
|
-
deadFrontBehavior: false;
|
|
30
|
-
lighting: true;
|
|
31
|
-
offOnly: false;
|
|
32
|
-
}>, {
|
|
33
|
-
deadFrontBehavior: false;
|
|
34
|
-
lighting: false;
|
|
35
|
-
offOnly: false;
|
|
36
|
-
}>, {
|
|
37
|
-
deadFrontBehavior: false;
|
|
38
|
-
lighting: true;
|
|
39
|
-
offOnly: false;
|
|
40
|
-
}>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors/on-off").OnOffBaseServer.Internal, "onOff">;
|
|
41
|
-
} & {
|
|
42
|
-
readonly scenesManagement: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").ScenesManagementServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/scenes-management").ScenesManagement, {
|
|
43
|
-
sceneNames: true;
|
|
44
|
-
}>, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").ScenesManagementServer.Internal, "scenesManagement">;
|
|
45
|
-
};
|
|
46
|
-
}>, import("@matter/node").SupportedBehaviors.With<{
|
|
47
|
-
readonly identify: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").IdentifyServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types/clusters/identify").Identify, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").IdentifyServer.Internal, "identify">;
|
|
48
|
-
} & {
|
|
49
|
-
readonly groups: typeof import("@matter/node/behaviors").GroupsServer;
|
|
50
|
-
} & {
|
|
51
|
-
readonly onOff: import("@matter/node").ClusterBehavior.Type<typeof OnOffServer, import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/on-off").OnOff, {
|
|
52
|
-
deadFrontBehavior: false;
|
|
53
|
-
lighting: true;
|
|
54
|
-
offOnly: false;
|
|
55
|
-
}>, {
|
|
56
|
-
deadFrontBehavior: false;
|
|
57
|
-
lighting: false;
|
|
58
|
-
offOnly: false;
|
|
59
|
-
}>, {
|
|
60
|
-
deadFrontBehavior: false;
|
|
61
|
-
lighting: true;
|
|
62
|
-
offOnly: false;
|
|
63
|
-
}>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors/on-off").OnOffBaseServer.Internal, "onOff">;
|
|
64
|
-
} & {
|
|
65
|
-
readonly scenesManagement: import("@matter/node").ClusterBehavior.Type<typeof import("@matter/node/behaviors").ScenesManagementServer, import("@matter/types").ClusterType.WithEnabledAttributes<import("@matter/types").ClusterType.WithEnabledEvents<import("@matter/types").ClusterType.WithSupportedFeatures<import("@matter/types/clusters/scenes-management").ScenesManagement, {
|
|
66
|
-
sceneNames: true;
|
|
67
|
-
}>, never>, never>, import("@matter/types").ClusterType.Concrete, typeof import("@matter/node/behaviors").ScenesManagementServer.Internal, "scenesManagement">;
|
|
68
|
-
}, readonly [typeof BridgedDeviceBasicInformationServer]>, {}>>>>;
|
|
16
|
+
export declare const addVirtualEndpointMatterbridgeSpy: import("jest-mock").Mock<(pluginName: string, name: string, type: "light" | "outlet" | "switch" | "mounted_switch", callback: () => Promise<void>) => Promise<boolean>>;
|
|
69
17
|
export declare function addMatterbridge(platform: object): void;
|
|
70
18
|
export declare function flushAllEndpointNumberPersistence(targetServer: ServerNode, rounds?: number, ticks?: number, microTurns?: number, pause?: number): Promise<void>;
|
|
71
19
|
export declare function assertAllEndpointNumbersPersisted(targetServer: ServerNode): Promise<number>;
|
package/dist/jestMatterTest.js
CHANGED
|
@@ -31,20 +31,20 @@ export async function createTestEnvironment() {
|
|
|
31
31
|
}
|
|
32
32
|
export async function destroyTestEnvironment() {
|
|
33
33
|
}
|
|
34
|
-
export
|
|
34
|
+
export function getMatterbridge() {
|
|
35
35
|
const matterbridge = {
|
|
36
36
|
systemInformation: {
|
|
37
37
|
interfaceName: 'eth0',
|
|
38
38
|
macAddress: 'aa:bb:cc:dd:ee:ff',
|
|
39
|
-
ipv4Address: '',
|
|
40
|
-
ipv6Address: '',
|
|
41
|
-
|
|
42
|
-
nodeVersion: '22.1.10',
|
|
39
|
+
ipv4Address: '192.168.68.100',
|
|
40
|
+
ipv6Address: 'fd78:cbf8:4939:46e2:51b2:2163:7f88:c33d',
|
|
41
|
+
nodeVersion: '24.16.0',
|
|
43
42
|
hostname: 'matterbridge',
|
|
44
43
|
user: 'jest',
|
|
45
44
|
osType: 'Linux',
|
|
45
|
+
osRelease: '6.8.0-xxxx',
|
|
46
46
|
osPlatform: 'linux',
|
|
47
|
-
osArch: '
|
|
47
|
+
osArch: 'arm64',
|
|
48
48
|
totalMemory: '0 B',
|
|
49
49
|
freeMemory: '0 B',
|
|
50
50
|
systemUptime: '0s',
|
|
@@ -77,47 +77,65 @@ export async function getMatterbridge() {
|
|
|
77
77
|
return matterbridge;
|
|
78
78
|
}
|
|
79
79
|
const addBridgedEndpoint = jest.fn(async (pluginName, device) => {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
try {
|
|
81
|
+
await aggregator.add(device);
|
|
82
|
+
return Promise.resolve(true);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return Promise.reject(error);
|
|
86
|
+
}
|
|
82
87
|
});
|
|
83
88
|
const removeBridgedEndpoint = jest.fn(async (pluginName, device) => {
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
try {
|
|
90
|
+
await device.delete();
|
|
91
|
+
return Promise.resolve(true);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return Promise.reject(error);
|
|
95
|
+
}
|
|
86
96
|
});
|
|
87
97
|
const removeAllBridgedEndpoints = jest.fn(async (pluginName, _delay = 0) => {
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
try {
|
|
99
|
+
for (const device of aggregator.parts) {
|
|
100
|
+
await device.delete();
|
|
101
|
+
}
|
|
102
|
+
return Promise.resolve(true);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return Promise.reject(error);
|
|
90
106
|
}
|
|
91
|
-
return Promise.resolve(true);
|
|
92
107
|
});
|
|
93
108
|
const addVirtualEndpoint = jest.fn(async (pluginName, name, type, callback) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
try {
|
|
110
|
+
const device = new Endpoint(MountedOnOffControlDevice.with(BridgedDeviceBasicInformationServer), {
|
|
111
|
+
id: name.replaceAll(' ', '') + ':' + type,
|
|
112
|
+
bridgedDeviceBasicInformation: {
|
|
113
|
+
vendorId: VendorId(0xfff1),
|
|
114
|
+
vendorName: 'Matterbridge',
|
|
115
|
+
productName: 'Matterbridge Virtual Device',
|
|
116
|
+
nodeLabel: name.slice(0, 32),
|
|
117
|
+
softwareVersion: 20000,
|
|
118
|
+
softwareVersionString: '2.0.0',
|
|
119
|
+
},
|
|
120
|
+
onOff: { onOff: false },
|
|
121
|
+
});
|
|
122
|
+
device.events.onOff.onOff$Changed.on((value) => {
|
|
123
|
+
if (value) {
|
|
124
|
+
void callback().catch(() => { });
|
|
125
|
+
void device.setStateOf(OnOffServer, { onOff: false }).catch(() => { });
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
await aggregator.add(device);
|
|
114
129
|
await device.act(async (agent) => {
|
|
115
130
|
const descriptor = await agent.load(DescriptorServer);
|
|
116
131
|
descriptor.addDeviceTypes('OnOffPlugInUnit');
|
|
117
132
|
});
|
|
133
|
+
await device.setStateOf(OnOffServer, { onOff: false });
|
|
134
|
+
return Promise.resolve(true);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
return Promise.reject(error);
|
|
118
138
|
}
|
|
119
|
-
await device.setStateOf(OnOffServer, { onOff: false });
|
|
120
|
-
return device;
|
|
121
139
|
});
|
|
122
140
|
export const addBridgedEndpointMatterbridgeSpy = addBridgedEndpoint;
|
|
123
141
|
export const removeBridgedEndpointMatterbridgeSpy = removeBridgedEndpoint;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/jest-utils",
|
|
3
|
-
"version": "3.8.1-dev-
|
|
3
|
+
"version": "3.8.1-dev-20260608-9dc483f",
|
|
4
4
|
"description": "Matterbridge jest 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.8.1-dev-
|
|
69
|
-
"node-ansi-logger": "3.3.0-dev-
|
|
68
|
+
"@matterbridge/types": "3.8.1-dev-20260608-9dc483f",
|
|
69
|
+
"node-ansi-logger": "3.3.0-dev-20260607-585945a"
|
|
70
70
|
}
|
|
71
71
|
}
|