diff --git a/__tests__/write/heosCommand.ts b/__tests__/write/heosCommand.ts index 08d710c..b71d408 100644 --- a/__tests__/write/heosCommand.ts +++ b/__tests__/write/heosCommand.ts @@ -17,7 +17,7 @@ describe('Heos commands can be correctly created', () => { expect(command).toEqual('heos://player/volume_up?pid=2&step=5\r\n') }) - test('A command can have no attributes', () => { + test('A command can have zero attributes', () => { const command = generateHeosCommand('system', 'heart_beat', {}) expect(command).toEqual('heos://system/heart_beat\r\n') @@ -28,4 +28,12 @@ describe('Heos commands can be correctly created', () => { expect(command).toEqual('heos://player/get_volume?pid=1\r\n') }) + + test('Strings are correctly encoded', () => { + const command = generateHeosCommand('system', 'register_for_change_events', { + enable: 'on' + }) + + expect(command).toEqual('heos://system/register_for_change_events?enable=on\r\n') + }) }) diff --git a/src/write/heosCommand.ts b/src/write/heosCommand.ts index 80fbad6..578b97d 100644 --- a/src/write/heosCommand.ts +++ b/src/write/heosCommand.ts @@ -10,13 +10,7 @@ function attributeString(attributes?: HeosCommandAttribute): string { return ( '?' + Object.entries(attributes) - .map(([key, value]) => { - if (typeof value === 'string') { - return `${key}='${value}'` - } else { - return `${key}=${value.toString()}` - } - }) + .map(([key, value]) => `${key}=${value}`) .reduce((previous, current) => `${previous}&${current}`) ) }