From 8e94d64ea0c478c37da0f0929c94b603f0f2c298 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Thu, 21 Sep 2023 14:28:15 +0200 Subject: [PATCH] fixup! test(binding-coap): `await` all calls of `coapServer.stop()` --- .../binding-coap/test/coap-server-test.ts | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/binding-coap/test/coap-server-test.ts b/packages/binding-coap/test/coap-server-test.ts index fa5b625ec..aee6a287f 100644 --- a/packages/binding-coap/test/coap-server-test.ts +++ b/packages/binding-coap/test/coap-server-test.ts @@ -336,29 +336,32 @@ class CoapServerTest { null, ]; - const promises = contentFormats.map((contentFormat) => new Promise((resolve) => { - const req = request(uri); - - if (contentFormat != null) { - req.setHeader("Accept", contentFormat); - } - - req.on("response", async (res: IncomingMessage) => { - const requestContentFormat = res.headers["Content-Format"]; - - if (contentFormat === unsupportedContentFormat) { - expect(res.code).to.equal("4.06"); - expect(res.payload.toString()).to.equal( - `Content-Format ${unsupportedContentFormat} is not supported by this resource.` - ); - } else { - expect(requestContentFormat).to.equal(contentFormat ?? defaultContentFormat); + const promises = contentFormats.map( + (contentFormat) => + new Promise((resolve) => { + const req = request(uri); + + if (contentFormat != null) { + req.setHeader("Accept", contentFormat); } - resolve(); - }); - req.end(); - })); + req.on("response", async (res: IncomingMessage) => { + const requestContentFormat = res.headers["Content-Format"]; + + if (contentFormat === unsupportedContentFormat) { + expect(res.code).to.equal("4.06"); + expect(res.payload.toString()).to.equal( + `Content-Format ${unsupportedContentFormat} is not supported by this resource.` + ); + } else { + expect(requestContentFormat).to.equal(contentFormat ?? defaultContentFormat); + } + + resolve(); + }); + req.end(); + }) + ); await Promise.all(promises);