32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import { OpenRGBIntegration, OpenRGBManualMatcher } from '../../ts/integrations/openrgb/index.js';
|
|
|
|
tap.test('config flow returns local OpenRGB SDK config and validates port', async () => {
|
|
const integration = new OpenRGBIntegration();
|
|
const step = await integration.configFlow.start({ source: 'manual', integrationDomain: 'openrgb', host: '192.168.1.20', name: 'Gaming PC' }, {});
|
|
const invalid = await step.submit?.({ name: 'Gaming PC', host: '192.168.1.20', port: 70000 });
|
|
const done = await step.submit?.({ name: 'Gaming PC', host: '192.168.1.20', port: 6742, clientName: 'Home Assistant' });
|
|
|
|
expect(invalid?.kind).toEqual('error');
|
|
expect(done?.kind).toEqual('done');
|
|
expect(done?.config?.host).toEqual('192.168.1.20');
|
|
expect(done?.config?.port).toEqual(6742);
|
|
expect(done?.config?.clientName).toEqual('Home Assistant');
|
|
});
|
|
|
|
tap.test('manual matcher recognizes OpenRGB SDK and snapshot candidates', async () => {
|
|
const match = await new OpenRGBManualMatcher().matches({
|
|
integrationDomain: 'openrgb',
|
|
host: '127.0.0.1',
|
|
port: 6742,
|
|
name: 'OpenRGB SDK Server',
|
|
metadata: { openrgb: true },
|
|
});
|
|
|
|
expect(match.matched).toBeTrue();
|
|
expect(match.candidate?.integrationDomain).toEqual('openrgb');
|
|
expect(match.candidate?.port).toEqual(6742);
|
|
});
|
|
|
|
export default tap.start();
|