@@ -6,6 +6,40 @@ import {
6
6
import { buildMessage } from "./message.ts" ;
7
7
import { Client } from "./client.ts" ;
8
8
9
+ Deno . test ( "Client.reply" , async ( t ) => {
10
+ await t . step ( "sends a message" , ( ) => {
11
+ const receives : unknown [ ] = [ ] ;
12
+ const session = {
13
+ send : ( message : unknown ) => {
14
+ receives . push ( message ) ;
15
+ } ,
16
+ recv : ( ) => {
17
+ throw new Error ( "should not be called" ) ;
18
+ } ,
19
+ } ;
20
+ const client = new Client ( session ) ;
21
+ client . reply ( 1 , "Hello" ) ;
22
+ client . reply ( 2 , "World" ) ;
23
+ assertEquals ( receives , [
24
+ [ 1 , "Hello" ] ,
25
+ [ 2 , "World" ] ,
26
+ ] ) ;
27
+ } ) ;
28
+
29
+ await t . step ( "throws an error when send fails" , ( ) => {
30
+ const session = {
31
+ send : ( ) => {
32
+ throw new Error ( "send error" ) ;
33
+ } ,
34
+ recv : ( ) => {
35
+ throw new Error ( "should not be called" ) ;
36
+ } ,
37
+ } ;
38
+ const client = new Client ( session ) ;
39
+ assertThrows ( ( ) => client . redraw ( ) , Error , "send error" ) ;
40
+ } ) ;
41
+ } ) ;
42
+
9
43
Deno . test ( "Client.redraw" , async ( t ) => {
10
44
await t . step ( "sends a redraw command" , ( ) => {
11
45
const receives : unknown [ ] = [ ] ;
0 commit comments