Skip to content

Commit

Permalink
fixup! test(binding-coap): await all calls of coapServer.stop()
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Sep 21, 2023
1 parent 3d5fbad commit 7b46440
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/binding-coap/test/coap-server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ class CoapServerTest {
await coapServer.expose(testThing);

const uri = `coap://localhost:${coapServer.getPort()}/test`;
let responseCounter = 0;

registerFormat("application/foobar", 65000);

Expand All @@ -337,9 +336,8 @@ class CoapServerTest {
null,
];

await new Promise<void>((resolve) => {
for (const contentFormat of contentFormats) {
const req = request(uri);
const promises = contentFormats.map((contentFormat) => new Promise<void>((resolve) => {
const req = request(uri);

if (contentFormat != null) {
req.setHeader("Accept", contentFormat);
Expand All @@ -357,13 +355,12 @@ class CoapServerTest {
expect(requestContentFormat).to.equal(contentFormat ?? defaultContentFormat);
}

if (++responseCounter >= contentFormats.length) {
resolve();
}
resolve();
});
req.end();
}
});
}));

await Promise.all(promises);

await coapServer.stop();
}
Expand Down

0 comments on commit 7b46440

Please sign in to comment.