steelseries-sonar-sdk 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +874 -0
- package/package.json +9 -3
- package/.gitattributes +0 -8
- package/.github/workflows/tests.yml +0 -18
- package/.vscode/extensions.json +0 -8
- package/.vscode/settings.json +0 -33
- package/_.todo +0 -4
- package/biome.json +0 -62
- package/http/sonar.http +0 -104
- package/src/consts/fetch-options-put.ts +0 -3
- package/src/enums.ts +0 -88
- package/src/exceptions.ts +0 -45
- package/src/functions/audio/get-audio-data-classic.ts +0 -31
- package/src/functions/audio/get-audio-data-stream.ts +0 -37
- package/src/functions/audio/get-audio-mode.ts +0 -11
- package/src/functions/audio/set-audio-mode.ts +0 -12
- package/src/functions/audio/set-channel-mute-classic.ts +0 -35
- package/src/functions/audio/set-channel-mute-streamer.ts +0 -41
- package/src/functions/audio/set-channel-volume-classic.ts +0 -37
- package/src/functions/audio/set-channel-volume-streamer.ts +0 -43
- package/src/functions/chatmix/get-chat-mix-state.ts +0 -20
- package/src/functions/chatmix/set-chat-mix-balance.ts +0 -22
- package/src/functions/converters/convert-channel-to-api.ts +0 -19
- package/src/functions/converters/convert-chat-mix-balance-to-api.ts +0 -6
- package/src/functions/converters/convert-chat-mix-balance-to-user.ts +0 -7
- package/src/functions/converters/convert-profile-channel-to-api.ts +0 -19
- package/src/functions/converters/convert-profile-channel-to-user.ts +0 -19
- package/src/functions/converters/convert-volume-to-api.ts +0 -5
- package/src/functions/converters/convert-volume-to-user.ts +0 -6
- package/src/functions/devices/get-audio-devices.ts +0 -40
- package/src/functions/devices/set-audio-device.ts +0 -19
- package/src/functions/endpoint/get-app-endpoint.ts +0 -73
- package/src/functions/endpoint/get-sonar-endpoint-cached.ts +0 -28
- package/src/functions/endpoint/get-sonar-endpoint.ts +0 -88
- package/src/functions/profile/get-channel-profiles.ts +0 -26
- package/src/functions/profile/get-selected-profiles.ts +0 -17
- package/src/functions/profile/set-selected-profile.ts +0 -17
- package/src/index.ts +0 -41
- package/src/sonar/models/audio-settings/chatmix-data.ts +0 -6
- package/src/sonar/models/audio-settings/enums/audio-mode.ts +0 -4
- package/src/sonar/models/audio-settings/enums/chat-mix-state.ts +0 -6
- package/src/sonar/models/audio-settings/enums/device-data-flow.ts +0 -5
- package/src/sonar/models/audio-settings/enums/device-default-roles.ts +0 -6
- package/src/sonar/models/audio-settings/enums/device-role.ts +0 -9
- package/src/sonar/models/audio-settings/enums/device-state.ts +0 -8
- package/src/sonar/models/audio-settings/enums/sonar-channel.ts +0 -8
- package/src/sonar/models/audio-settings/enums/streaming-path.ts +0 -4
- package/src/sonar/models/audio-settings/volume-info-classic.ts +0 -4
- package/src/sonar/models/audio-settings/volume-info-streamer.ts +0 -10
- package/src/sonar/models/audio-settings/volume-settings-classic.ts +0 -13
- package/src/sonar/models/audio-settings/volume-settings-streamer.ts +0 -13
- package/src/sonar/models/config/config.ts +0 -9
- package/src/sonar/models/config/enums/VirtualAudioDevice.ts +0 -7
- package/src/sonar/models/devices/audio-device.ts +0 -17
- package/src/sonar/models/devices/changed-device.ts +0 -7
- package/src/sonar/requests/audio-devices/change-audio-device.ts +0 -37
- package/src/sonar/requests/audio-devices/request-audio-devices.ts +0 -42
- package/src/sonar/requests/chatmix/change-chat-mix-balance.ts +0 -25
- package/src/sonar/requests/chatmix/request-chat-mix-state.ts +0 -24
- package/src/sonar/requests/mode/change-audio-mode.ts +0 -24
- package/src/sonar/requests/mode/request-audio-mode.ts +0 -24
- package/src/sonar/requests/profiles/change-selected-config.ts +0 -25
- package/src/sonar/requests/profiles/request-configs.ts +0 -24
- package/src/sonar/requests/profiles/request-selected-configs.ts +0 -22
- package/src/sonar/requests/volume-settings/change-volume-level-classic.ts +0 -27
- package/src/sonar/requests/volume-settings/change-volume-level-streamer.ts +0 -29
- package/src/sonar/requests/volume-settings/change-volume-mute-classic.ts +0 -27
- package/src/sonar/requests/volume-settings/change-volume-mute-streamer.ts +0 -29
- package/src/sonar/requests/volume-settings/request-volume-settings-classic.ts +0 -22
- package/src/sonar/requests/volume-settings/request-volume-settings-streamer.ts +0 -22
- package/src/types/audio-device.ts +0 -7
- package/src/types/changed-device.ts +0 -7
- package/src/types/channel-volume-classic.ts +0 -4
- package/src/types/channel-volume-streamer-path.ts +0 -4
- package/src/types/channel-volume-streamer.ts +0 -6
- package/src/types/channel-volumes-classic.ts +0 -8
- package/src/types/channel-volumes-streamer.ts +0 -8
- package/src/types/chat-mix-data.ts +0 -7
- package/src/types/profile-option.ts +0 -9
- package/tests/e2e/audio/get-audio-data-classic.real.test.ts +0 -11
- package/tests/e2e/audio/get-audio-data-stream.real.test.ts +0 -11
- package/tests/e2e/audio/get-audio-mode.real.test.ts +0 -12
- package/tests/e2e/audio/set-audio-mode.real.test.ts +0 -20
- package/tests/e2e/audio/set-channel-mute-classic.real.test.ts +0 -18
- package/tests/e2e/audio/set-channel-mute-streamer.real.test.ts +0 -18
- package/tests/e2e/audio/set-channel-volume-classic.real.test.ts +0 -17
- package/tests/e2e/audio/set-channel-volume-streamer.real.test.ts +0 -22
- package/tests/e2e/chatmix/get-chat-mix-state.real.test.ts +0 -25
- package/tests/e2e/chatmix/set-chat-mix-balance.real.test.ts +0 -25
- package/tests/e2e/devices/get-audio-devices.real.test.ts +0 -29
- package/tests/e2e/devices/set-audio-device.real.test.ts +0 -32
- package/tests/e2e/enpoint/get-app-endpoint.real.test.ts +0 -19
- package/tests/e2e/enpoint/get-sonar-endpoint-cached.real.test.ts +0 -32
- package/tests/e2e/enpoint/get-sonar-endpoint.real.test.ts +0 -21
- package/tests/e2e/profiles/get-channel-profiles.real.test.ts +0 -21
- package/tests/e2e/profiles/get-selected-profiles.real.test.ts +0 -11
- package/tests/e2e/profiles/set-selected-profile.real.test.ts +0 -17
- package/tests/helpers/get-endpoint-e2e.ts +0 -8
- package/tests/unit/audio/get-audio-data-classic.test.ts +0 -57
- package/tests/unit/audio/get-audio-data-stream.test.ts +0 -65
- package/tests/unit/audio/get-audio-mode.test.ts +0 -58
- package/tests/unit/audio/set-audio-mode.test.ts +0 -66
- package/tests/unit/audio/set-channel-mute-classic.test.ts +0 -58
- package/tests/unit/audio/set-channel-mute-streamer.test.ts +0 -64
- package/tests/unit/audio/set-channel-volume-classic.test.ts +0 -58
- package/tests/unit/audio/set-channel-volume-streamer.test.ts +0 -64
- package/tests/unit/chatmix/get-chat-mix-state.test.ts +0 -70
- package/tests/unit/chatmix/set-chat-mix-balance.test.ts +0 -58
- package/tests/unit/devices/get-audio-devices.test.ts +0 -59
- package/tests/unit/devices/set-audio-devices.test.ts +0 -62
- package/tests/unit/endpoint/get-app-endpoint.test.ts +0 -72
- package/tests/unit/endpoint/get-sonar-endpoint-cached.test.ts +0 -93
- package/tests/unit/endpoint/get-sonar-endpoint.test.ts +0 -140
- package/tests/unit/profiles/get-channel-profiles.test.ts +0 -91
- package/tests/unit/profiles/get-selected-profiles.test.ts +0 -64
- package/tests/unit/profiles/set-selected-profile.test.ts +0 -55
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -36
- /package/{src → dist}/consts/fetch-options-put.d.ts +0 -0
- /package/{src → dist}/enums.d.ts +0 -0
- /package/{src → dist}/exceptions.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-data-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-data-stream.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-mode.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-audio-mode.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-mute-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-mute-streamer.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-volume-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-volume-streamer.d.ts +0 -0
- /package/{src → dist}/functions/chatmix/get-chat-mix-state.d.ts +0 -0
- /package/{src → dist}/functions/chatmix/set-chat-mix-balance.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-channel-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-user.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-profile-channel-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-profile-channel-to-user.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-volume-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-volume-to-user.d.ts +0 -0
- /package/{src → dist}/functions/devices/get-audio-devices.d.ts +0 -0
- /package/{src → dist}/functions/devices/set-audio-device.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-app-endpoint.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-sonar-endpoint-cached.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-sonar-endpoint.d.ts +0 -0
- /package/{src → dist}/functions/profile/get-channel-profiles.d.ts +0 -0
- /package/{src → dist}/functions/profile/get-selected-profiles.d.ts +0 -0
- /package/{src → dist}/functions/profile/set-selected-profile.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/chatmix-data.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/chat-mix-state.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-data-flow.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-default-roles.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-role.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-state.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/sonar-channel.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/streaming-path.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-info-classic.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-info-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-settings-classic.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-settings-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/models/config/config.d.ts +0 -0
- /package/{src → dist}/sonar/models/config/enums/VirtualAudioDevice.d.ts +0 -0
- /package/{src → dist}/sonar/models/devices/audio-device.d.ts +0 -0
- /package/{src → dist}/sonar/models/devices/changed-device.d.ts +0 -0
- /package/{src → dist}/sonar/requests/audio-devices/change-audio-device.d.ts +0 -0
- /package/{src → dist}/sonar/requests/audio-devices/request-audio-devices.d.ts +0 -0
- /package/{src → dist}/sonar/requests/chatmix/change-chat-mix-balance.d.ts +0 -0
- /package/{src → dist}/sonar/requests/chatmix/request-chat-mix-state.d.ts +0 -0
- /package/{src → dist}/sonar/requests/mode/change-audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/requests/mode/request-audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/change-selected-config.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/request-configs.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/request-selected-configs.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-streamer.d.ts +0 -0
- /package/{src → dist}/types/audio-device.d.ts +0 -0
- /package/{src → dist}/types/changed-device.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-classic.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-streamer-path.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-streamer.d.ts +0 -0
- /package/{src → dist}/types/channel-volumes-classic.d.ts +0 -0
- /package/{src → dist}/types/channel-volumes-streamer.d.ts +0 -0
- /package/{src → dist}/types/chat-mix-data.d.ts +0 -0
- /package/{src → dist}/types/profile-option.d.ts +0 -0
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { AudioMode, ChatMixState } from '@/enums'
|
|
4
|
-
import { setAudioMode } from '@/functions/audio/set-audio-mode'
|
|
5
|
-
import { getChatMixState } from '@/functions/chatmix/get-chat-mix-state'
|
|
6
|
-
|
|
7
|
-
describe('getChatMixState', () => {
|
|
8
|
-
it('returns enabled state when classic', async () => {
|
|
9
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
10
|
-
await setAudioMode(sonarEndpoint, AudioMode.Classic)
|
|
11
|
-
const result = await getChatMixState(sonarEndpoint)
|
|
12
|
-
expect(result).not.toBeNull()
|
|
13
|
-
expect(result.state).toBe(ChatMixState.Enabled)
|
|
14
|
-
expect(result.isEnabled).toBeTrue()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('returns disabled state when streamer', async () => {
|
|
18
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
19
|
-
await setAudioMode(sonarEndpoint, AudioMode.Streamer)
|
|
20
|
-
const result = await getChatMixState(sonarEndpoint)
|
|
21
|
-
expect(result).not.toBeNull()
|
|
22
|
-
expect(result.state).toBe(ChatMixState.FiniteWheel)
|
|
23
|
-
expect(result.isEnabled).toBeFalse()
|
|
24
|
-
})
|
|
25
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { AudioMode, ChatMixState } from '@/enums'
|
|
4
|
-
import { SonarRequestException } from '@/exceptions'
|
|
5
|
-
import { setAudioMode } from '@/functions/audio/set-audio-mode'
|
|
6
|
-
import { setChatMixBalance } from '@/functions/chatmix/set-chat-mix-balance'
|
|
7
|
-
|
|
8
|
-
describe('setChatBalance', () => {
|
|
9
|
-
it('returns balance when classic mode', async () => {
|
|
10
|
-
const expectedBalance = 70
|
|
11
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
12
|
-
await setAudioMode(sonarEndpoint, AudioMode.Classic)
|
|
13
|
-
const result = await setChatMixBalance(sonarEndpoint, expectedBalance)
|
|
14
|
-
expect(result).not.toBeNull()
|
|
15
|
-
expect(result.state).toBe(ChatMixState.Enabled)
|
|
16
|
-
expect(result.isEnabled).toBeTrue()
|
|
17
|
-
expect(result.chatBalance).toBe(expectedBalance)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('throws when streamer mode enabled', async () => {
|
|
21
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
22
|
-
await setAudioMode(sonarEndpoint, AudioMode.Streamer)
|
|
23
|
-
expect(setChatMixBalance(sonarEndpoint, 0)).rejects.toThrow(SonarRequestException)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { DeviceFlow } from '@/enums'
|
|
4
|
-
import { getAudioDevices } from '@/functions/devices/get-audio-devices'
|
|
5
|
-
|
|
6
|
-
describe('getAudioDevices', () => {
|
|
7
|
-
it('returns audio devices for input', async () => {
|
|
8
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
9
|
-
const result = await getAudioDevices(sonarEndpoint, DeviceFlow.Input)
|
|
10
|
-
expect(result.length).toBeGreaterThan(0)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('returns audio devices for output', async () => {
|
|
14
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
15
|
-
const result = await getAudioDevices(sonarEndpoint, DeviceFlow.Output)
|
|
16
|
-
expect(result.length).toBeGreaterThan(0)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('returns combined audio devices for all', async () => {
|
|
20
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
21
|
-
const resultInput = await getAudioDevices(sonarEndpoint, DeviceFlow.Input)
|
|
22
|
-
const resultOutput = await getAudioDevices(sonarEndpoint, DeviceFlow.Output)
|
|
23
|
-
const resultAll = await getAudioDevices(sonarEndpoint)
|
|
24
|
-
expect(resultInput.length).toBeGreaterThan(0)
|
|
25
|
-
expect(resultOutput.length).toBeGreaterThan(0)
|
|
26
|
-
expect(resultAll.length).toBeGreaterThan(0)
|
|
27
|
-
expect(resultAll.length).toBe(resultInput.length + resultOutput.length)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { DeviceChannel } from '@/enums'
|
|
4
|
-
import { setAudioDevice } from '@/functions/devices/set-audio-device'
|
|
5
|
-
|
|
6
|
-
const OUTPUT_DEVICE_ID = '{0.0.0.00000000}.{0e5b2eb2-8d10-4e5f-b757-59a3e15def98}'
|
|
7
|
-
const INPUT_DEVICE_ID = '{0.0.1.00000000}.{7b82ae46-28f8-4adb-bdd2-fa08863bc5b7}'
|
|
8
|
-
|
|
9
|
-
describe('setAudioDevice', () => {
|
|
10
|
-
it('throws when input set to output', async () => {
|
|
11
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
12
|
-
expect(setAudioDevice(sonarEndpoint, DeviceChannel.Mic, OUTPUT_DEVICE_ID)).rejects.toThrow()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('returns set audio devices for all output', async () => {
|
|
16
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
17
|
-
const result = await setAudioDevice(sonarEndpoint, DeviceChannel.Output, OUTPUT_DEVICE_ID)
|
|
18
|
-
expect(result.length).toBe(4)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('returns set audio device for output-aux', async () => {
|
|
22
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
23
|
-
const result = await setAudioDevice(sonarEndpoint, DeviceChannel.Aux, OUTPUT_DEVICE_ID)
|
|
24
|
-
expect(result.length).toBe(1)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('returns set audio device for input', async () => {
|
|
28
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
29
|
-
const result = await setAudioDevice(sonarEndpoint, DeviceChannel.Mic, INPUT_DEVICE_ID)
|
|
30
|
-
expect(result.length).toBe(1)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getAppEndpoint } from '@/functions/endpoint/get-app-endpoint'
|
|
3
|
-
|
|
4
|
-
const logs: string[] = []
|
|
5
|
-
|
|
6
|
-
afterEach(() => {
|
|
7
|
-
for (const log of logs) {
|
|
8
|
-
console.log(log)
|
|
9
|
-
}
|
|
10
|
-
logs.length = 0
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
describe('getAppEndpoint', () => {
|
|
14
|
-
it('returns ggEncryptedAddress', async () => {
|
|
15
|
-
const result = await getAppEndpoint()
|
|
16
|
-
expect(result).toBeString()
|
|
17
|
-
logs.push(`> app address: ${result}`)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, spyOn } from 'bun:test'
|
|
2
|
-
import { getAppEndpoint } from '@/functions/endpoint/get-app-endpoint'
|
|
3
|
-
import { getSonarEndpointCached } from '@/functions/endpoint/get-sonar-endpoint-cached'
|
|
4
|
-
|
|
5
|
-
const logs: string[] = []
|
|
6
|
-
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
for (const log of logs) {
|
|
9
|
-
console.log(log)
|
|
10
|
-
}
|
|
11
|
-
logs.length = 0
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const spy = spyOn(globalThis, 'fetch')
|
|
15
|
-
|
|
16
|
-
describe('getSonarEndpointCached', () => {
|
|
17
|
-
it('returns sonarAddress', async () => {
|
|
18
|
-
const appAddress = await getAppEndpoint()
|
|
19
|
-
const sonarAddress = await getSonarEndpointCached(appAddress)
|
|
20
|
-
expect(sonarAddress).toBeString()
|
|
21
|
-
logs.push(`> sonar address: ${sonarAddress}`)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('returns cached sonarAddress', async () => {
|
|
25
|
-
const appAddress = await getAppEndpoint()
|
|
26
|
-
await getSonarEndpointCached(appAddress)
|
|
27
|
-
const sonarAddress = await getSonarEndpointCached(appAddress)
|
|
28
|
-
expect(sonarAddress).toBeString()
|
|
29
|
-
expect(spy).toHaveBeenCalledTimes(1)
|
|
30
|
-
logs.push(`> sonar address: ${sonarAddress}`)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getAppEndpoint } from '@/functions/endpoint/get-app-endpoint'
|
|
3
|
-
import { getSonarEndpoint } from '@/functions/endpoint/get-sonar-endpoint'
|
|
4
|
-
|
|
5
|
-
const logs: string[] = []
|
|
6
|
-
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
for (const log of logs) {
|
|
9
|
-
console.log(log)
|
|
10
|
-
}
|
|
11
|
-
logs.length = 0
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
describe('getSonarEndpoint', () => {
|
|
15
|
-
it('returns sonarAddress', async () => {
|
|
16
|
-
const appAddress = await getAppEndpoint()
|
|
17
|
-
const sonarAddress = await getSonarEndpoint(appAddress)
|
|
18
|
-
expect(sonarAddress).toBeString()
|
|
19
|
-
logs.push(`> sonar address: ${sonarAddress}`)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { ProfileChannel } from '@/enums'
|
|
4
|
-
import { getChannelProfiles } from '@/functions/profile/get-channel-profiles'
|
|
5
|
-
|
|
6
|
-
describe('getChannelProfiles', () => {
|
|
7
|
-
it('returns list of profiles', async () => {
|
|
8
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
9
|
-
const result = await getChannelProfiles(sonarEndpoint, ProfileChannel.Game)
|
|
10
|
-
expect(result.length).toBeGreaterThan(1)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('returns list of favorite profiles only', async () => {
|
|
14
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
15
|
-
const allProfiles = await getChannelProfiles(sonarEndpoint, ProfileChannel.Game)
|
|
16
|
-
const favoriteProfiles = await getChannelProfiles(sonarEndpoint, ProfileChannel.Game, true)
|
|
17
|
-
expect(allProfiles.length).toBeGreaterThan(1)
|
|
18
|
-
expect(favoriteProfiles.length).toBeGreaterThan(1)
|
|
19
|
-
expect(favoriteProfiles.length).toBeLessThan(allProfiles.length)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { getSelectedProfiles } from '@/functions/profile/get-selected-profiles'
|
|
4
|
-
|
|
5
|
-
describe('getSelectedProfiles', () => {
|
|
6
|
-
it('returns list of selected profiles', async () => {
|
|
7
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
8
|
-
const result = await getSelectedProfiles(sonarEndpoint)
|
|
9
|
-
expect(result.length).toBeGreaterThanOrEqual(2)
|
|
10
|
-
})
|
|
11
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { getEndpointEndToEnd } from 'tests/helpers/get-endpoint-e2e'
|
|
3
|
-
import { setSelectedProfile } from '@/functions/profile/set-selected-profile'
|
|
4
|
-
|
|
5
|
-
const INITIAL_PROFILE = 'e6979db3-3e00-4399-b58c-6f026c9ef6ba'
|
|
6
|
-
const CHANGED_PROFILE = 'c55f5f17-db23-4b0e-805c-02fd3ba39636'
|
|
7
|
-
|
|
8
|
-
describe('setSelectedProfiles', () => {
|
|
9
|
-
it('sets profile successfully', async () => {
|
|
10
|
-
const sonarEndpoint = await getEndpointEndToEnd()
|
|
11
|
-
const initial = await setSelectedProfile(sonarEndpoint, INITIAL_PROFILE)
|
|
12
|
-
const changed = await setSelectedProfile(sonarEndpoint, CHANGED_PROFILE)
|
|
13
|
-
expect(initial.id).toBe(INITIAL_PROFILE)
|
|
14
|
-
expect(changed.id).toBe(CHANGED_PROFILE)
|
|
15
|
-
expect(initial.id).not.toBe(changed.id)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { getAppEndpoint } from '../../src/functions/endpoint/get-app-endpoint'
|
|
2
|
-
import { getSonarEndpoint } from '../../src/functions/endpoint/get-sonar-endpoint'
|
|
3
|
-
|
|
4
|
-
export async function getEndpointEndToEnd() {
|
|
5
|
-
const appEndpoint = await getAppEndpoint()
|
|
6
|
-
const sonarEndpoint = await getSonarEndpoint(appEndpoint)
|
|
7
|
-
return sonarEndpoint
|
|
8
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { SonarRequestException } from '@/exceptions'
|
|
3
|
-
import { getAudioDataClassic } from '@/functions/audio/get-audio-data-classic'
|
|
4
|
-
|
|
5
|
-
let originalFetch: typeof fetch
|
|
6
|
-
|
|
7
|
-
const request = () => getAudioDataClassic('https://localhost')
|
|
8
|
-
|
|
9
|
-
describe('getAudioDataClassic', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
originalFetch = globalThis.fetch
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
globalThis.fetch = originalFetch
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('throws SonarException when response not 200', async () => {
|
|
19
|
-
globalThis.fetch = (async () =>
|
|
20
|
-
({
|
|
21
|
-
ok: false,
|
|
22
|
-
json: async () => 'Some error occurred'
|
|
23
|
-
}) as Response) as unknown as typeof fetch
|
|
24
|
-
|
|
25
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
29
|
-
globalThis.fetch = (async () =>
|
|
30
|
-
({
|
|
31
|
-
ok: true,
|
|
32
|
-
json: async () => ({})
|
|
33
|
-
}) as Response) as unknown as typeof fetch
|
|
34
|
-
|
|
35
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('return data when response 200', async () => {
|
|
39
|
-
globalThis.fetch = (async () =>
|
|
40
|
-
({
|
|
41
|
-
ok: true,
|
|
42
|
-
json: async () => ({
|
|
43
|
-
masters: {
|
|
44
|
-
classic: {
|
|
45
|
-
volume: 0.49,
|
|
46
|
-
muted: false
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
devices: {}
|
|
50
|
-
})
|
|
51
|
-
}) as Response) as unknown as typeof fetch
|
|
52
|
-
|
|
53
|
-
const response = await request()
|
|
54
|
-
expect(response.master.volume).toBe(49)
|
|
55
|
-
expect(response.master.isMuted).toBe(false)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { SonarRequestException } from '@/exceptions'
|
|
3
|
-
import { getAudioDataStream } from '@/functions/audio/get-audio-data-stream'
|
|
4
|
-
|
|
5
|
-
let originalFetch: typeof fetch
|
|
6
|
-
|
|
7
|
-
const request = () => getAudioDataStream('https://localhost')
|
|
8
|
-
|
|
9
|
-
describe('getAudioDataStream', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
originalFetch = globalThis.fetch
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
globalThis.fetch = originalFetch
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('throws SonarException when response not 200', async () => {
|
|
19
|
-
globalThis.fetch = (async () =>
|
|
20
|
-
({
|
|
21
|
-
ok: false,
|
|
22
|
-
json: async () => 'Some error occurred'
|
|
23
|
-
}) as Response) as unknown as typeof fetch
|
|
24
|
-
|
|
25
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
29
|
-
globalThis.fetch = (async () =>
|
|
30
|
-
({
|
|
31
|
-
ok: true,
|
|
32
|
-
json: async () => ({})
|
|
33
|
-
}) as Response) as unknown as typeof fetch
|
|
34
|
-
|
|
35
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('return data when response 200', async () => {
|
|
39
|
-
globalThis.fetch = (async () =>
|
|
40
|
-
({
|
|
41
|
-
ok: true,
|
|
42
|
-
json: async () => ({
|
|
43
|
-
masters: {
|
|
44
|
-
stream: {
|
|
45
|
-
streaming: {
|
|
46
|
-
volume: 0.49,
|
|
47
|
-
muted: true
|
|
48
|
-
},
|
|
49
|
-
monitoring: {
|
|
50
|
-
volume: 0.48,
|
|
51
|
-
muted: false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
devices: {}
|
|
56
|
-
})
|
|
57
|
-
}) as Response) as unknown as typeof fetch
|
|
58
|
-
|
|
59
|
-
const response = await request()
|
|
60
|
-
expect(response.master.streaming.volume).toBe(49)
|
|
61
|
-
expect(response.master.streaming.isMuted).toBe(true)
|
|
62
|
-
expect(response.master.monitoring.volume).toBe(48)
|
|
63
|
-
expect(response.master.monitoring.isMuted).toBe(false)
|
|
64
|
-
})
|
|
65
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { AudioMode } from '@/enums'
|
|
3
|
-
import { SonarRequestException } from '@/exceptions'
|
|
4
|
-
import { getAudioMode } from '@/functions/audio/get-audio-mode'
|
|
5
|
-
|
|
6
|
-
let originalFetch: typeof fetch
|
|
7
|
-
|
|
8
|
-
const request = () => getAudioMode('https://localhost')
|
|
9
|
-
|
|
10
|
-
describe('getAudioMode', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
originalFetch = globalThis.fetch
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
globalThis.fetch = originalFetch
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('throws SonarException when response not 200', async () => {
|
|
20
|
-
globalThis.fetch = (async () =>
|
|
21
|
-
({
|
|
22
|
-
ok: false,
|
|
23
|
-
text: async () => 'Some error occurred'
|
|
24
|
-
}) as Response) as unknown as typeof fetch
|
|
25
|
-
|
|
26
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
30
|
-
globalThis.fetch = (async () =>
|
|
31
|
-
({
|
|
32
|
-
ok: true,
|
|
33
|
-
json: async () => ({})
|
|
34
|
-
}) as Response) as unknown as typeof fetch
|
|
35
|
-
|
|
36
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('return classic when response 200', async () => {
|
|
40
|
-
globalThis.fetch = (async () =>
|
|
41
|
-
({
|
|
42
|
-
ok: true,
|
|
43
|
-
json: async () => AudioMode.Classic
|
|
44
|
-
}) as Response) as unknown as typeof fetch
|
|
45
|
-
|
|
46
|
-
expect(request()).resolves.toBe(AudioMode.Classic)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('return streamer when response 200', async () => {
|
|
50
|
-
globalThis.fetch = (async () =>
|
|
51
|
-
({
|
|
52
|
-
ok: true,
|
|
53
|
-
json: async () => AudioMode.Streamer
|
|
54
|
-
}) as Response) as unknown as typeof fetch
|
|
55
|
-
|
|
56
|
-
expect(request()).resolves.toBe(AudioMode.Streamer)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { AudioMode } from '@/enums'
|
|
3
|
-
import { SonarRequestException } from '@/exceptions'
|
|
4
|
-
import { setAudioMode } from '@/functions/audio/set-audio-mode'
|
|
5
|
-
|
|
6
|
-
let originalFetch: typeof fetch
|
|
7
|
-
|
|
8
|
-
const request = (mode: AudioMode) => setAudioMode('https://localhost', mode)
|
|
9
|
-
|
|
10
|
-
describe('setAudioMode', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
originalFetch = globalThis.fetch
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
globalThis.fetch = originalFetch
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('throws SonarException when response not 200', async () => {
|
|
20
|
-
globalThis.fetch = (async () =>
|
|
21
|
-
({
|
|
22
|
-
ok: false,
|
|
23
|
-
text: async () => 'Some error occurred'
|
|
24
|
-
}) as Response) as unknown as typeof fetch
|
|
25
|
-
|
|
26
|
-
const method = request(AudioMode.Classic)
|
|
27
|
-
|
|
28
|
-
expect(method).rejects.toThrow(SonarRequestException)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
32
|
-
globalThis.fetch = (async () =>
|
|
33
|
-
({
|
|
34
|
-
ok: true,
|
|
35
|
-
json: async () => ({})
|
|
36
|
-
}) as Response) as unknown as typeof fetch
|
|
37
|
-
|
|
38
|
-
const method = request(AudioMode.Classic)
|
|
39
|
-
|
|
40
|
-
expect(method).rejects.toThrow(SonarRequestException)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('return classic when response 200', async () => {
|
|
44
|
-
globalThis.fetch = (async () =>
|
|
45
|
-
({
|
|
46
|
-
ok: true,
|
|
47
|
-
json: async () => AudioMode.Classic
|
|
48
|
-
}) as Response) as unknown as typeof fetch
|
|
49
|
-
|
|
50
|
-
const method = request(AudioMode.Classic)
|
|
51
|
-
|
|
52
|
-
expect(method).resolves.toBe(AudioMode.Classic)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('return streamer when response 200', async () => {
|
|
56
|
-
globalThis.fetch = (async () =>
|
|
57
|
-
({
|
|
58
|
-
ok: true,
|
|
59
|
-
json: async () => AudioMode.Streamer
|
|
60
|
-
}) as Response) as unknown as typeof fetch
|
|
61
|
-
|
|
62
|
-
const method = request(AudioMode.Streamer)
|
|
63
|
-
|
|
64
|
-
expect(method).resolves.toBe(AudioMode.Streamer)
|
|
65
|
-
})
|
|
66
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { AudioChannel } from '@/enums'
|
|
3
|
-
import { SonarRequestException } from '@/exceptions'
|
|
4
|
-
import { setChannelMuteClassic } from '@/functions/audio/set-channel-mute-classic'
|
|
5
|
-
|
|
6
|
-
let originalFetch: typeof fetch
|
|
7
|
-
|
|
8
|
-
const request = () => setChannelMuteClassic('https://localhost', true, AudioChannel.Master)
|
|
9
|
-
|
|
10
|
-
describe('setChannelMuteClassic', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
originalFetch = globalThis.fetch
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
globalThis.fetch = originalFetch
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('throws SonarException when response not 200', async () => {
|
|
20
|
-
globalThis.fetch = (async () =>
|
|
21
|
-
({
|
|
22
|
-
ok: false,
|
|
23
|
-
json: async () => 'Some error occurred'
|
|
24
|
-
}) as Response) as unknown as typeof fetch
|
|
25
|
-
|
|
26
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
30
|
-
globalThis.fetch = (async () =>
|
|
31
|
-
({
|
|
32
|
-
ok: true,
|
|
33
|
-
json: async () => ({})
|
|
34
|
-
}) as Response) as unknown as typeof fetch
|
|
35
|
-
|
|
36
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('return data when response 200', async () => {
|
|
40
|
-
globalThis.fetch = (async () =>
|
|
41
|
-
({
|
|
42
|
-
ok: true,
|
|
43
|
-
json: async () => ({
|
|
44
|
-
masters: {
|
|
45
|
-
classic: {
|
|
46
|
-
volume: 0.49,
|
|
47
|
-
muted: false
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
devices: {}
|
|
51
|
-
})
|
|
52
|
-
}) as Response) as unknown as typeof fetch
|
|
53
|
-
|
|
54
|
-
const response = await request()
|
|
55
|
-
expect(response.volume).toBe(49)
|
|
56
|
-
expect(response.isMuted).toBe(false)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { AudioChannel, StreamerPath } from '@/enums'
|
|
3
|
-
import { SonarRequestException } from '@/exceptions'
|
|
4
|
-
import { setChannelMuteStreamer } from '@/functions/audio/set-channel-mute-streamer'
|
|
5
|
-
|
|
6
|
-
let originalFetch: typeof fetch
|
|
7
|
-
|
|
8
|
-
const request = () => setChannelMuteStreamer('https://localhost', false, AudioChannel.Master, StreamerPath.Streaming)
|
|
9
|
-
|
|
10
|
-
describe('setChannelMuteStreamer', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
originalFetch = globalThis.fetch
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
globalThis.fetch = originalFetch
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('throws SonarException when response not 200', async () => {
|
|
20
|
-
globalThis.fetch = (async () =>
|
|
21
|
-
({
|
|
22
|
-
ok: false,
|
|
23
|
-
json: async () => 'Some error occurred'
|
|
24
|
-
}) as Response) as unknown as typeof fetch
|
|
25
|
-
|
|
26
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
30
|
-
globalThis.fetch = (async () =>
|
|
31
|
-
({
|
|
32
|
-
ok: true,
|
|
33
|
-
json: async () => ({})
|
|
34
|
-
}) as Response) as unknown as typeof fetch
|
|
35
|
-
|
|
36
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('return data when response 200', async () => {
|
|
40
|
-
globalThis.fetch = (async () =>
|
|
41
|
-
({
|
|
42
|
-
ok: true,
|
|
43
|
-
json: async () => ({
|
|
44
|
-
masters: {
|
|
45
|
-
stream: {
|
|
46
|
-
streaming: {
|
|
47
|
-
volume: 0.49,
|
|
48
|
-
muted: true
|
|
49
|
-
},
|
|
50
|
-
monitoring: {
|
|
51
|
-
volume: 0.48,
|
|
52
|
-
muted: false
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
devices: {}
|
|
57
|
-
})
|
|
58
|
-
}) as Response) as unknown as typeof fetch
|
|
59
|
-
|
|
60
|
-
const response = await request()
|
|
61
|
-
expect(response.volume).toBe(49)
|
|
62
|
-
expect(response.isMuted).toBe(true)
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
|
|
2
|
-
import { AudioChannel } from '@/enums'
|
|
3
|
-
import { SonarRequestException } from '@/exceptions'
|
|
4
|
-
import { setChannelVolumeClassic } from '@/functions/audio/set-channel-volume-classic'
|
|
5
|
-
|
|
6
|
-
let originalFetch: typeof fetch
|
|
7
|
-
|
|
8
|
-
const request = () => setChannelVolumeClassic('https://localhost', 75, AudioChannel.Master)
|
|
9
|
-
|
|
10
|
-
describe('setChannelVolumeClassic', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
originalFetch = globalThis.fetch
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
globalThis.fetch = originalFetch
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('throws SonarException when response not 200', async () => {
|
|
20
|
-
globalThis.fetch = (async () =>
|
|
21
|
-
({
|
|
22
|
-
ok: false,
|
|
23
|
-
json: async () => 'Some error occurred'
|
|
24
|
-
}) as Response) as unknown as typeof fetch
|
|
25
|
-
|
|
26
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('throws SonarException when response 200 but not data', async () => {
|
|
30
|
-
globalThis.fetch = (async () =>
|
|
31
|
-
({
|
|
32
|
-
ok: true,
|
|
33
|
-
json: async () => ({})
|
|
34
|
-
}) as Response) as unknown as typeof fetch
|
|
35
|
-
|
|
36
|
-
expect(request()).rejects.toThrow(SonarRequestException)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('return data when response 200', async () => {
|
|
40
|
-
globalThis.fetch = (async () =>
|
|
41
|
-
({
|
|
42
|
-
ok: true,
|
|
43
|
-
json: async () => ({
|
|
44
|
-
masters: {
|
|
45
|
-
classic: {
|
|
46
|
-
volume: 0.49,
|
|
47
|
-
muted: false
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
devices: {}
|
|
51
|
-
})
|
|
52
|
-
}) as Response) as unknown as typeof fetch
|
|
53
|
-
|
|
54
|
-
const response = await request()
|
|
55
|
-
expect(response.volume).toBe(49)
|
|
56
|
-
expect(response.isMuted).toBe(false)
|
|
57
|
-
})
|
|
58
|
-
})
|