-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load DescriptorServer before changing (#1344)
* Load DescriptorServer before changing ... to prevent locking issues when not fully initialized. fixes #1339 * FIx example paths fixes #1343 * Fix example paths * Add PowerSourceServer test Confirmed not working before last change to PowerSourceServer but works now --------- Co-authored-by: Greg Lauckhart <[email protected]>
- Loading branch information
Showing
10 changed files
with
78 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/node/test/behaviors/power-source/PowerSourceServerTest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @license | ||
* Copyright 2022-2024 Matter.js Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PowerSourceDt } from "@matter/model"; | ||
import { PowerSource } from "@matter/types/clusters/power-source"; | ||
import { PowerSourceServer } from "../../../src/behaviors/power-source/PowerSourceServer.js"; | ||
import { HumiditySensorDevice } from "../../../src/devices/humidity-sensor.js"; | ||
import { MockEndpoint } from "../../endpoint/mock-endpoint.js"; | ||
import { MockServerNode } from "../../node/mock-server-node.js"; | ||
|
||
describe("PowerSourceServer", () => { | ||
it("successfully augments descriptor", async () => { | ||
const node = new MockServerNode(); | ||
const sensor = new MockEndpoint( | ||
HumiditySensorDevice.with( | ||
PowerSourceServer.with(PowerSource.Feature.Battery, PowerSource.Feature.Replaceable).set({ | ||
status: PowerSource.PowerSourceStatus.Active, | ||
order: 1, | ||
description: "aa batteries", | ||
batChargeLevel: PowerSource.BatChargeLevel.Ok, | ||
batReplacementNeeded: false, | ||
batReplaceability: PowerSource.BatReplaceability.UserReplaceable, | ||
batReplacementDescription: "open, replace", | ||
batQuantity: 2, | ||
}), | ||
), | ||
{ owner: node }, | ||
); | ||
await node.add(sensor); | ||
expect(sensor.state.descriptor.deviceTypeList).deep.equals([ | ||
{ deviceType: HumiditySensorDevice.deviceType, revision: HumiditySensorDevice.deviceRevision }, | ||
{ deviceType: PowerSourceDt.id, revision: PowerSourceDt.revision }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters