From 74d7bb90c7fe2a59ef8bd353b03ed26d2ec1f258 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 15 Nov 2022 15:32:34 +1100 Subject: [PATCH] test: compare all messages at once Makes it easier to understand the order mismatch. --- packages/tests/tests/store.node.spec.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/tests/tests/store.node.spec.ts b/packages/tests/tests/store.node.spec.ts index 62a56c8315..b7ff8c5076 100644 --- a/packages/tests/tests/store.node.spec.ts +++ b/packages/tests/tests/store.node.spec.ts @@ -225,13 +225,8 @@ describe("Waku Store", () => { ); expect(messages?.length).eq(totalMsgs); - for (let index = 0; index < totalMsgs; index++) { - expect( - messages?.findIndex((msg) => { - return msg.payload![0]! === index; - }) - ).to.eq(index); - } + const payloads = messages.map((msg) => msg.payload![0]!); + expect(payloads).to.deep.eq(Array.from(Array(totalMsgs).keys())); }); it("Ordered Callback - Backward", async function () { @@ -270,13 +265,8 @@ describe("Waku Store", () => { messages = messages.reverse(); expect(messages?.length).eq(totalMsgs); - for (let index = 0; index < totalMsgs; index++) { - expect( - messages?.findIndex((msg) => { - return msg.payload![0]! === index; - }) - ).to.eq(index); - } + const payloads = messages.map((msg) => msg.payload![0]!); + expect(payloads).to.deep.eq(Array.from(Array(totalMsgs).keys())); }); it("Generator, with asymmetric & symmetric encrypted messages", async function () {