-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.ts
40 lines (35 loc) · 1000 Bytes
/
client_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { assertObjectMatch } from "jsr:@std/assert";
import { Client } from "./client.ts";
import { MessageType } from "./types/message_type.ts";
Deno.test("client", async (test) => {
const url = Deno.args[0];
if (!url) {
throw new Error(`WebSocket URL not found! Pass URL as first CLI argument`);
}
const client = new Client(url);
await client.register();
await test.step("volumeUp", async () => {
const res = await client.sendMessage({
type: MessageType.REQUEST,
uri: "ssap://audio/volumeUp",
});
assertObjectMatch({
volume: 8,
returnValue: true,
soundOutput: "tv_external_speaker",
}, res);
});
await test.step("volumeDown", async () => {
const res = await client.sendMessage({
type: MessageType.REQUEST,
uri: "ssap://audio/volumeDown",
});
assertObjectMatch({
volume: 7,
returnValue: true,
soundOutput: "tv_external_speaker",
}, res);
});
client.close();
Deno.exit(0);
});