-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from Luligu/dev
Release 1.2.3
- Loading branch information
Showing
8 changed files
with
524 additions
and
428 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ replay_pid* | |
temp | ||
src/mock | ||
jest | ||
matterstorage | ||
matterstorage.backup |
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 |
---|---|---|
|
@@ -168,3 +168,5 @@ create-release.js | |
tsconfig.* | ||
temp | ||
jest | ||
matterstorage | ||
matterstorage.backup |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,84 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { Matterbridge, MatterbridgeDevice, MatterbridgeEndpoint, PlatformConfig } from 'matterbridge'; | ||
import { Matterbridge, MatterbridgeEndpoint, PlatformConfig } from 'matterbridge'; | ||
import { AnsiLogger } from 'matterbridge/logger'; | ||
import { SomfyTahomaPlatform } from './platform.js'; | ||
import initializePlugin from './index'; | ||
import { jest } from '@jest/globals'; | ||
|
||
describe('initializePlugin', () => { | ||
let mockMatterbridge: Matterbridge; | ||
let mockLog: AnsiLogger; | ||
let mockConfig: PlatformConfig; | ||
const mockLog = { | ||
fatal: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.fatal', message, parameters); | ||
}), | ||
error: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.error', message, parameters); | ||
}), | ||
warn: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.warn', message, parameters); | ||
}), | ||
notice: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.notice', message, parameters); | ||
}), | ||
info: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.info', message, parameters); | ||
}), | ||
debug: jest.fn((message: string, ...parameters: any[]) => { | ||
// console.log('mockLog.debug', message, parameters); | ||
}), | ||
} as unknown as AnsiLogger; | ||
|
||
const mockMatterbridge = { | ||
matterbridgeDirectory: './jest/matterbridge', | ||
matterbridgePluginDirectory: './jest/plugins', | ||
systemInformation: { ipv4Address: undefined, ipv6Address: undefined, osRelease: 'xx.xx.xx.xx.xx.xx', nodeVersion: '22.1.10' }, | ||
matterbridgeVersion: '2.1.0', | ||
edge: true, | ||
log: mockLog, | ||
getDevices: jest.fn(() => { | ||
// console.log('getDevices called'); | ||
return []; | ||
}), | ||
getPlugins: jest.fn(() => { | ||
// console.log('getDevices called'); | ||
return []; | ||
}), | ||
addBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { | ||
// console.log('addBridgedEndpoint called'); | ||
}), | ||
removeBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { | ||
// console.log('removeBridgedEndpoint called'); | ||
}), | ||
removeAllBridgedEndpoints: jest.fn(async (pluginName: string) => { | ||
// console.log('removeAllBridgedEndpoints called'); | ||
}), | ||
} as unknown as Matterbridge; | ||
|
||
const mockConfig = { | ||
'name': 'matterbridge-somfy-tahoma', | ||
'type': 'DynamicPlatform', | ||
'username': 'None', | ||
'password': 'None', | ||
'service': 'somfy_europe', | ||
'blackList': [], | ||
'whiteList': [], | ||
'debug': false, | ||
'unregisterOnShutdown': false, | ||
} as PlatformConfig; | ||
|
||
beforeEach(() => { | ||
mockMatterbridge = { | ||
matterbridgeDirectory: './jest/matterbridge', | ||
matterbridgePluginDirectory: './jest/plugins', | ||
systemInformation: { ipv4Address: undefined }, | ||
matterbridgeVersion: '1.6.7', | ||
getDevices: jest.fn(() => { | ||
// console.log('getDevices called'); | ||
return []; | ||
}), | ||
addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { | ||
// console.log('addBridgedDevice called'); | ||
}), | ||
addBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { | ||
// console.log('addBridgedEndpoint called'); | ||
// await aggregator.add(device); | ||
}), | ||
removeBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { | ||
// console.log('removeBridgedDevice called'); | ||
}), | ||
removeBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { | ||
// console.log('removeBridgedEndpoint called'); | ||
}), | ||
removeAllBridgedDevices: jest.fn(async (pluginName: string) => { | ||
// console.log('removeAllBridgedDevices called'); | ||
}), | ||
removeAllBridgedEndpoints: jest.fn(async (pluginName: string) => { | ||
// console.log('removeAllBridgedEndpoints called'); | ||
}), | ||
} as unknown as Matterbridge; | ||
mockLog = { error: jest.fn(), warn: jest.fn(), info: jest.fn(), debug: jest.fn() } as unknown as AnsiLogger; | ||
mockConfig = { | ||
'name': 'matterbridge-somfy-tahoma', | ||
'type': 'DynamicPlatform', | ||
'username': 'None', | ||
'password': 'None', | ||
'service': 'somfy_europe', | ||
'blackList': [], | ||
'whiteList': [], | ||
'debug': false, | ||
'unregisterOnShutdown': false, | ||
} as PlatformConfig; | ||
// Clear all mocks. | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
afterAll(async () => { | ||
// Restore all mocks. | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('should return an instance of SomfyTahomaPlatform', () => { | ||
it('should return an instance of SomfyTahomaPlatform', async () => { | ||
const result = initializePlugin(mockMatterbridge, mockLog, mockConfig); | ||
expect(result).toBeInstanceOf(SomfyTahomaPlatform); | ||
await result.onShutdown(); | ||
}); | ||
}); |
Oops, something went wrong.