Add macOS companion node status and system.nodes APIs
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
parseNodeRegisterParams,
|
||||
parseNodeLocationSetParams,
|
||||
parseNodeLocationGetParams,
|
||||
parseNodeStatusSetParams,
|
||||
makeResponse,
|
||||
makeError,
|
||||
makeEvent,
|
||||
@@ -171,6 +172,45 @@ describe('protocol', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseNodeStatusSetParams', () => {
|
||||
it('parses valid node status set params', () => {
|
||||
const parsed = parseNodeStatusSetParams({
|
||||
connectionId: 'conn-1',
|
||||
platform: 'macos',
|
||||
appVersion: '0.1.0',
|
||||
deviceName: 'Willbook',
|
||||
statusText: 'Idle',
|
||||
batteryPct: 73,
|
||||
powerSource: 'battery',
|
||||
});
|
||||
expect(parsed).toEqual({
|
||||
connectionId: 'conn-1',
|
||||
platform: 'macos',
|
||||
appVersion: '0.1.0',
|
||||
deviceName: 'Willbook',
|
||||
statusText: 'Idle',
|
||||
batteryPct: 73,
|
||||
powerSource: 'battery',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects invalid node status set params', () => {
|
||||
expect(parseNodeStatusSetParams({
|
||||
connectionId: 'conn-1',
|
||||
platform: 'beos',
|
||||
})).toBeNull();
|
||||
expect(parseNodeStatusSetParams({
|
||||
connectionId: 'conn-1',
|
||||
platform: 'macos',
|
||||
batteryPct: 120,
|
||||
})).toBeNull();
|
||||
expect(parseNodeStatusSetParams({
|
||||
connectionId: '',
|
||||
platform: 'macos',
|
||||
})).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('makeResponse', () => {
|
||||
it('creates a response message', () => {
|
||||
expect(makeResponse(1, { status: 'ok' })).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user