From f84631a6bfd6c77977209960faf7b4ffdf5ef866 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 9 Oct 2024 05:43:59 +0200 Subject: [PATCH] performance: add for loop break condition in the test --- src/app/user/Stake/StakingContext.test.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/user/Stake/StakingContext.test.tsx b/src/app/user/Stake/StakingContext.test.tsx index e173c01f..74775956 100644 --- a/src/app/user/Stake/StakingContext.test.tsx +++ b/src/app/user/Stake/StakingContext.test.tsx @@ -33,9 +33,9 @@ const actionName = 'STAKE' describe('StakingProvider', () => { it('Amount to receive is a whole number if the stake amount is also a whole number and the token prices are equal', () => { - const failingCases: string[] = [] + let allTestsPass = true - // running the test 500 times + // running the test 500 times with different stake amounts and token prices for (let i = 0; i < 500; i++) { // stake amount is a whole number const stakeAmount = i.toString() @@ -57,9 +57,10 @@ describe('StakingProvider', () => { // if amount to receive is not a whole number // or if the amount to receive is not equal to the stake amount if (amountToReceive.textContent?.includes('.') || stakeAmount !== amountToReceive.textContent) { - failingCases.push(price) + allTestsPass = false + break } } - expect(failingCases.length).toBe(0) + expect(allTestsPass).toBe(true) }) })