Skip to content

Commit

Permalink
Dev 1.6.2-dev.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Nov 11, 2024
1 parent 06ff23f commit 846b289
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/matterbridgeDevice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ import { MatterbridgeDevice } from './matterbridgeDevice.js';

describe('Matterbridge device serialize/deserialize', () => {
test('create a basic device with all default clusters', async () => {
const device = new MatterbridgeDevice(DeviceTypes.ON_OFF_LIGHT);
let device = new MatterbridgeDevice(DeviceTypes.ON_OFF_LIGHT);
expect(device.getDeviceTypes()).toHaveLength(1);
MatterbridgeDevice.bridgeMode = 'bridge';
device.createDefaultBasicInformationClusterServer('Name', 'Serial', 1, 'VendorName', 1, 'ProductName');
expect(device.getDeviceTypes()).toHaveLength(2);
MatterbridgeDevice.bridgeMode = '';
device = new MatterbridgeDevice(DeviceTypes.ON_OFF_LIGHT);
device.createDefaultBasicInformationClusterServer('Name', 'Serial', 1, 'VendorName', 1, 'ProductName');
device.createDefaultBasicInformationClusterServer('Name', 'Serial', 1, 'VendorName', 1, 'ProductName', 1, '1.0.0', 1, '1.0.0');
device.createDefaultIdentifyClusterServer();
Expand All @@ -67,14 +70,14 @@ describe('Matterbridge device serialize/deserialize', () => {
device.createDefaultOnOffClusterServer();
expect(device.getDeviceTypes()).toHaveLength(1);
expect(() => device.verifyRequiredClusters()).not.toThrow();
expect(device.getAllClusterServers()).toHaveLength(7);
expect(device.getAllClusterServers()).toHaveLength(6);
const serialized = device.serialize();
expect(serialized).toBeDefined();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const deserialized = MatterbridgeDevice.deserialize(serialized!);
expect(deserialized).toBeDefined();
expect(deserialized.getDeviceTypes()).toHaveLength(1);
expect(deserialized.getAllClusterServers()).toHaveLength(7);
expect(deserialized.getAllClusterServers()).toHaveLength(6);
expect(() => deserialized.verifyRequiredClusters()).not.toThrow();
});

Expand Down

0 comments on commit 846b289

Please # to comment.