Skip to content

Commit

Permalink
Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Jul 5, 2024
1 parent f83b605 commit 4339b8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/matterbridgeDevice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,17 @@ describe('Matterbridge platform', () => {
child?.verifyRequiredClusters();
// eslint-disable-next-line jest/no-conditional-expect
if (child) expect(device.getChildEndpointName(child)).toBe('ComposedDevice3');

child = device.getChildEndpointWithLabel('ComposedDevice1');
// eslint-disable-next-line jest/no-conditional-expect
if (child) expect(device.getChildEndpointName(child)).toBe('ComposedDevice1');

child = device.getChildEndpointWithLabel('ComposedDevice2');
// eslint-disable-next-line jest/no-conditional-expect
if (child) expect(device.getChildEndpointName(child)).toBe('ComposedDevice2');

child = device.getChildEndpointWithLabel('ComposedDevice3');
// eslint-disable-next-line jest/no-conditional-expect
if (child) expect(device.getChildEndpointName(child)).toBe('ComposedDevice3');
});
});
3 changes: 1 addition & 2 deletions src/matterbridgeDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods<typeof Device
* @returns {Endpoint | undefined} The child endpoint with the specified label, or undefined if not found.
*/
getChildEndpointWithLabel(label: string): Endpoint | undefined {
const endpoints = this.getChildEndpoints();
for (const endpoint of endpoints) {
for (const endpoint of this.getChildEndpoints()) {
const labelList = endpoint.getClusterServer(FixedLabelCluster)?.getLabelListAttribute();
if (!labelList) return undefined;
let endpointName = '';
Expand Down

0 comments on commit 4339b8e

Please sign in to comment.