From 3a0f37771cbb5ee6f8c510b3f3a5ceebd61e2eb6 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Fri, 5 Jan 2024 17:22:38 +0100 Subject: [PATCH] test: refactoring --- .../tests/api/accounts.test.ts | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/packages/integration-tests/tests/api/accounts.test.ts b/packages/integration-tests/tests/api/accounts.test.ts index 9aae1d390a..7ace717697 100644 --- a/packages/integration-tests/tests/api/accounts.test.ts +++ b/packages/integration-tests/tests/api/accounts.test.ts @@ -88,40 +88,38 @@ describe("Accounts API", () => { await setTimeout(localConfig.extendedPause); //works unstable without timeout - return ( - request(environment.blockExplorerAPI) - .get(apiRoute) - .expect(200) - .expect((res) => expect(res.body.result.length).toBeGreaterThan(1)) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ status: "1" }))) - .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ message: "OK" }))) - .expect((res) => expect(typeof res.body.result[0].blockNumber).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].timeStamp).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].hash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].nonce).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].blockHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].from).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].to).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].value).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].gas).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].isError).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].txreceipt_status).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].input).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].contractAddress).toBeTruthy()) // can be null - .expect((res) => expect(typeof res.body.result[0].cumulativeGasUsed).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].confirmations).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].fee).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].commitTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].proveTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].executeTxHash).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].isL1Originated).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].l1BatchNumber).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].methodId).toStrictEqual("string")) - .expect((res) => expect(typeof res.body.result[0].functionName).toStrictEqual("string")) - ); + return request(environment.blockExplorerAPI) + .get(apiRoute) + .expect(200) + .expect((res) => expect(res.body.result.length).toBeGreaterThan(1)) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ status: "1" }))) + .expect((res) => expect(res.body).toStrictEqual(expect.objectContaining({ message: "OK" }))) + .expect((res) => expect(typeof res.body.result[0].blockNumber).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].timeStamp).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].hash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].nonce).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].blockHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].transactionIndex).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].from).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].to).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].value).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].gas).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].gasPrice).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].isError).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].txreceipt_status).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].input).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].contractAddress).toBeTruthy()) // can be null + .expect((res) => expect(typeof res.body.result[0].cumulativeGasUsed).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].gasUsed).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].confirmations).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].fee).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].commitTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].proveTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].executeTxHash).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].isL1Originated).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].l1BatchNumber).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].methodId).toStrictEqual("string")) + .expect((res) => expect(typeof res.body.result[0].functionName).toStrictEqual("string")); } ); });