@@ -2,24 +2,25 @@ import {
2
2
assertEquals ,
3
3
assertRejects ,
4
4
assertThrows ,
5
- } from "https://deno.land/std@0.186 .0/testing/asserts .ts" ;
5
+ } from "https://deno.land/std@0.210 .0/assert/mod .ts" ;
6
6
import { buildMessage } from "./message.ts" ;
7
7
import { Client } from "./client.ts" ;
8
8
9
9
Deno . test ( "Client.reply" , async ( t ) => {
10
- await t . step ( "sends a message" , ( ) => {
10
+ await t . step ( "sends a message" , async ( ) => {
11
11
const receives : unknown [ ] = [ ] ;
12
12
const session = {
13
13
send : ( message : unknown ) => {
14
14
receives . push ( message ) ;
15
+ return Promise . resolve ( ) ;
15
16
} ,
16
17
recv : ( ) => {
17
18
throw new Error ( "should not be called" ) ;
18
19
} ,
19
20
} ;
20
21
const client = new Client ( session ) ;
21
- client . reply ( 1 , "Hello" ) ;
22
- client . reply ( 2 , "World" ) ;
22
+ await client . reply ( 1 , "Hello" ) ;
23
+ await client . reply ( 2 , "World" ) ;
23
24
assertEquals ( receives , [
24
25
[ 1 , "Hello" ] ,
25
26
[ 2 , "World" ] ,
@@ -41,19 +42,20 @@ Deno.test("Client.reply", async (t) => {
41
42
} ) ;
42
43
43
44
Deno . test ( "Client.redraw" , async ( t ) => {
44
- await t . step ( "sends a redraw command" , ( ) => {
45
+ await t . step ( "sends a redraw command" , async ( ) => {
45
46
const receives : unknown [ ] = [ ] ;
46
47
const session = {
47
48
send : ( message : unknown ) => {
48
49
receives . push ( message ) ;
50
+ return Promise . resolve ( ) ;
49
51
} ,
50
52
recv : ( ) => {
51
53
throw new Error ( "should not be called" ) ;
52
54
} ,
53
55
} ;
54
56
const client = new Client ( session ) ;
55
- client . redraw ( ) ;
56
- client . redraw ( true ) ;
57
+ await client . redraw ( ) ;
58
+ await client . redraw ( true ) ;
57
59
assertEquals ( receives , [
58
60
[ "redraw" , "" ] ,
59
61
[ "redraw" , "force" ] ,
@@ -75,18 +77,19 @@ Deno.test("Client.redraw", async (t) => {
75
77
} ) ;
76
78
77
79
Deno . test ( "Client.ex" , async ( t ) => {
78
- await t . step ( "sends a ex command" , ( ) => {
80
+ await t . step ( "sends a ex command" , async ( ) => {
79
81
const receives : unknown [ ] = [ ] ;
80
82
const session = {
81
83
send : ( message : unknown ) => {
82
84
receives . push ( message ) ;
85
+ return Promise . resolve ( ) ;
83
86
} ,
84
87
recv : ( ) => {
85
88
throw new Error ( "should not be called" ) ;
86
89
} ,
87
90
} ;
88
91
const client = new Client ( session ) ;
89
- client . ex ( "echo 'Hello'" ) ;
92
+ await client . ex ( "echo 'Hello'" ) ;
90
93
assertEquals ( receives , [
91
94
[ "ex" , "echo 'Hello'" ] ,
92
95
] ) ;
@@ -107,18 +110,19 @@ Deno.test("Client.ex", async (t) => {
107
110
} ) ;
108
111
109
112
Deno . test ( "Client.normal" , async ( t ) => {
110
- await t . step ( "sends a normal command" , ( ) => {
113
+ await t . step ( "sends a normal command" , async ( ) => {
111
114
const receives : unknown [ ] = [ ] ;
112
115
const session = {
113
116
send : ( message : unknown ) => {
114
117
receives . push ( message ) ;
118
+ return Promise . resolve ( ) ;
115
119
} ,
116
120
recv : ( ) => {
117
121
throw new Error ( "should not be called" ) ;
118
122
} ,
119
123
} ;
120
124
const client = new Client ( session ) ;
121
- client . normal ( "zO" ) ;
125
+ await client . normal ( "zO" ) ;
122
126
assertEquals ( receives , [
123
127
[ "normal" , "zO" ] ,
124
128
] ) ;
@@ -144,6 +148,7 @@ Deno.test("Client.expr", async (t) => {
144
148
const session = {
145
149
send : ( message : unknown ) => {
146
150
receives . push ( message ) ;
151
+ return Promise . resolve ( ) ;
147
152
} ,
148
153
recv : ( msgid : number ) =>
149
154
Promise . resolve ( buildMessage ( msgid , `response:${ msgid } ` ) ) ,
@@ -163,7 +168,7 @@ Deno.test("Client.expr", async (t) => {
163
168
] ) ;
164
169
} ) ;
165
170
166
- await t . step ( "throws an error when send fails" , ( ) => {
171
+ await t . step ( "rejects with an error when send fails" , async ( ) => {
167
172
const session = {
168
173
send : ( ) => {
169
174
throw new Error ( "send error" ) ;
@@ -172,7 +177,7 @@ Deno.test("Client.expr", async (t) => {
172
177
Promise . resolve ( buildMessage ( msgid , `response:${ msgid } ` ) ) ,
173
178
} ;
174
179
const client = new Client ( session ) ;
175
- assertThrows (
180
+ await assertRejects (
176
181
( ) => client . expr ( "g:vim_deno_channel_command" ) ,
177
182
Error ,
178
183
"send error" ,
@@ -183,6 +188,7 @@ Deno.test("Client.expr", async (t) => {
183
188
const session = {
184
189
send : ( ) => {
185
190
// Do NOTHING
191
+ return Promise . resolve ( ) ;
186
192
} ,
187
193
recv : ( ) => {
188
194
throw new Error ( "recv error" ) ;
@@ -198,18 +204,19 @@ Deno.test("Client.expr", async (t) => {
198
204
} ) ;
199
205
200
206
Deno . test ( "Client.exprNoReply" , async ( t ) => {
201
- await t . step ( "sends a expr command" , ( ) => {
207
+ await t . step ( "sends a expr command" , async ( ) => {
202
208
const receives : unknown [ ] = [ ] ;
203
209
const session = {
204
210
send : ( message : unknown ) => {
205
211
receives . push ( message ) ;
212
+ return Promise . resolve ( ) ;
206
213
} ,
207
214
recv : ( ) => {
208
215
throw new Error ( "should not be called" ) ;
209
216
} ,
210
217
} ;
211
218
const client = new Client ( session ) ;
212
- client . exprNoReply ( "g:vim_deno_channel_command" ) ;
219
+ await client . exprNoReply ( "g:vim_deno_channel_command" ) ;
213
220
assertEquals ( receives , [
214
221
[ "expr" , "g:vim_deno_channel_command" ] ,
215
222
] ) ;
@@ -239,6 +246,7 @@ Deno.test("Client.call", async (t) => {
239
246
const session = {
240
247
send : ( message : unknown ) => {
241
248
receives . push ( message ) ;
249
+ return Promise . resolve ( ) ;
242
250
} ,
243
251
recv : ( msgid : number ) =>
244
252
Promise . resolve ( buildMessage ( msgid , `response:${ msgid } ` ) ) ,
@@ -252,7 +260,7 @@ Deno.test("Client.call", async (t) => {
252
260
] ) ;
253
261
} ) ;
254
262
255
- await t . step ( "throws an error when send fails" , ( ) => {
263
+ await t . step ( "rejects with an error when send fails" , async ( ) => {
256
264
const session = {
257
265
send : ( ) => {
258
266
throw new Error ( "send error" ) ;
@@ -261,7 +269,7 @@ Deno.test("Client.call", async (t) => {
261
269
Promise . resolve ( buildMessage ( msgid , `response:${ msgid } ` ) ) ,
262
270
} ;
263
271
const client = new Client ( session ) ;
264
- assertThrows (
272
+ await assertRejects (
265
273
( ) => client . call ( "foo" , "bar" ) ,
266
274
Error ,
267
275
"send error" ,
@@ -272,6 +280,7 @@ Deno.test("Client.call", async (t) => {
272
280
const session = {
273
281
send : ( ) => {
274
282
// Do NOTHING
283
+ return Promise . resolve ( ) ;
275
284
} ,
276
285
recv : ( ) => {
277
286
throw new Error ( "recv error" ) ;
@@ -287,18 +296,19 @@ Deno.test("Client.call", async (t) => {
287
296
} ) ;
288
297
289
298
Deno . test ( "Client.callNoReply" , async ( t ) => {
290
- await t . step ( "sends a call command" , ( ) => {
299
+ await t . step ( "sends a call command" , async ( ) => {
291
300
const receives : unknown [ ] = [ ] ;
292
301
const session = {
293
302
send : ( message : unknown ) => {
294
303
receives . push ( message ) ;
304
+ return Promise . resolve ( ) ;
295
305
} ,
296
306
recv : ( ) => {
297
307
throw new Error ( "should not be called" ) ;
298
308
} ,
299
309
} ;
300
310
const client = new Client ( session ) ;
301
- client . callNoReply ( "foo" , "bar" ) ;
311
+ await client . callNoReply ( "foo" , "bar" ) ;
302
312
assertEquals ( receives , [
303
313
[ "call" , "foo" , [ "bar" ] ] ,
304
314
] ) ;
0 commit comments