From 1fae8a5c5f67802de5cfe694bb743249d935c03e Mon Sep 17 00:00:00 2001 From: Luligu Date: Wed, 12 Feb 2025 12:34:32 +0100 Subject: [PATCH] Dev 2.1.6-dev.1 --- CHANGELOG.md | 1 + src/matterbridgePlatform.test.ts | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b49d90d4..50064007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ matterbridge-hass v. 0.0.8 - [docker]: Added health check directly inside the docker image. No need to change configuration. - [platform]: Added saving to storage the selects for faster loading. +- [icon]: Added matterbridge svg icon (thanks: https://github.com/robvanoostenrijk https://github.com/stuntguy3000). - [frontend]: Frontend v.2.4.2. diff --git a/src/matterbridgePlatform.test.ts b/src/matterbridgePlatform.test.ts index 856eace4..cf792e98 100644 --- a/src/matterbridgePlatform.test.ts +++ b/src/matterbridgePlatform.test.ts @@ -306,14 +306,25 @@ describe('Matterbridge platform', () => { platform.config.deviceEntityBlackList = {}; }); + test('should check checkNotLatinCharacters', async () => { + const testDevice = new MatterbridgeEndpoint(contactSensor, { uniqueStorageKey: 'nonLatin' }, true); + testDevice.createDefaultBasicInformationClusterServer('nonLatin조명', 'serial012345', 0xfff1, 'Matterbridge', 0x8001, 'Test device'); + testDevice.addRequiredClusterServers(); + await platform.registerDevice(testDevice); + expect(platform.hasDeviceName('nonLatin조명')).toBeTruthy(); + expect(platform.hasDeviceName('none')).toBeFalsy(); + expect(platform.registeredEndpoints.has(testDevice.uniqueId ?? 'none')).toBeTruthy(); + expect(platform.registeredEndpointsByName.has('nonLatin조명')).toBeTruthy(); + }); + test('checkEndpointNumbers should be empty', async () => { - const context = await platform.storage?.createStorage('context'); + const context = await platform.storage?.createStorage('endpointNumbers'); await context?.set('endpointMap', []); expect(await platform.checkEndpointNumbers()).toBe(0); }); test('checkEndpointNumbers should not validate without uniqueId', async () => { - const context = await platform.storage?.createStorage('context'); + const context = await platform.storage?.createStorage('endpointNumbers'); await context?.set('endpointMap', []); const testDevice = new MatterbridgeEndpoint(contactSensor, { uniqueStorageKey: 'test' }, true); testDevice.uniqueId = 'test'; @@ -325,12 +336,17 @@ describe('Matterbridge platform', () => { }); test('checkEndpointNumbers should not be empty', async () => { - const context = await platform.storage?.createStorage('context'); + const context = await platform.storage?.createStorage('endpointNumbers'); await context?.set('endpointMap', []); const testDevice = new MatterbridgeEndpoint(contactSensor, { uniqueStorageKey: 'test' }, true); testDevice.createDefaultBasicInformationClusterServer('test', 'serial01234', 0xfff1, 'Matterbridge', 0x8001, 'Test device'); testDevice.addRequiredClusterServers(); await platform.registerDevice(testDevice); + expect(platform.hasDeviceName('test')).toBeTruthy(); + expect(platform.hasDeviceName('none')).toBeFalsy(); + expect(platform.registeredEndpoints.has(testDevice.uniqueId ?? 'none')).toBeTruthy(); + expect(platform.registeredEndpointsByName.has('test')).toBeTruthy(); + testDevice.number = 100; (matterbridge as any).devices.set(testDevice); expect(await platform.checkEndpointNumbers()).toBe(1); @@ -430,11 +446,12 @@ describe('Matterbridge platform', () => { await platform.registerDevice(testDevice); testDevice.number = 101; (matterbridge as any).devices.set(testDevice); - expect(await testDevice.getChildEndpoints()).toHaveLength(2); + expect(testDevice.getChildEndpoints()).toHaveLength(2); jest.clearAllMocks(); expect(await platform.checkEndpointNumbers()).toBe(3); - expect(loggerLogSpy).toHaveBeenCalledTimes(4); + expect(loggerLogSpy).toHaveBeenCalledTimes(5); expect(loggerLogSpy).toHaveBeenCalledWith(LogLevel.DEBUG, 'Checking endpoint numbers...'); + expect(loggerLogSpy).toHaveBeenCalledWith(LogLevel.DEBUG, 'Saving endpointNumbers...'); expect(loggerLogSpy).toHaveBeenCalledWith(LogLevel.DEBUG, 'Endpoint numbers check completed.'); });