Skip to content

Commit eafe147

Browse files
committed
socket: simplify test with expectAsync()
1 parent 55a4ec8 commit eafe147

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

packages/socket/src/socketwrapper.spec.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ const enabled = !!globalThis.process?.env.SOCKETSERVER_ENABLED;
320320
});
321321

322322
it("cannot send on a disconnect socket (it will never come back)", async () => {
323-
let done!: (() => void) & { fail: (e?: any) => void };
323+
let done!: ((p?: void | PromiseLike<void>) => void) & { fail: (e?: any) => void };
324324
const ret = new Promise<void>((resolve, reject) => {
325325
done = resolve as typeof done;
326326
done.fail = reject;
@@ -338,15 +338,7 @@ const enabled = !!globalThis.process?.env.SOCKETSERVER_ENABLED;
338338
socket.disconnect();
339339
},
340340
() => {
341-
socket
342-
.send("la li lu")
343-
.then(() => {
344-
done.fail("must not resolve");
345-
})
346-
.catch((error) => {
347-
expect(error.message).toMatch(/socket was closed/i);
348-
done();
349-
});
341+
done(expectAsync(socket.send("la li lu")).toBeRejectedWithError(/socket was closed/i));
350342
},
351343
);
352344
socket.connect();

0 commit comments

Comments
 (0)