Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
manelgavalda committed Nov 10, 2023
1 parent 123aca1 commit 0d05951
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions tests/Feature/Livewire/TokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@
fakeRequest('https://fake-tokens-url.com', 'new_tokens');

Livewire::test(Tokens::class)
->assertViewHasAll([
'tokens' => fn ($tokens) => count($tokens) == 30,
'balances' => fn ($balances) => count($balances['prices']) == 31
&& count($balances['totals']) == 31
&& count($balances['ethereum']) == 31
&& count($balances['prices_eur']) == 31
&& count($balances['totals_eur']) == 31
])->dispatch('tokens-loaded')
->assertViewHasAll([
'tokens' => fn ($tokens) => count($tokens) == 31,
'balances' => fn ($balances) => count($balances['prices']) == 32
&& count($balances['totals']) == 32
&& count($balances['ethereum']) == 32
&& count($balances['prices_eur']) == 32
&& count($balances['totals_eur']) == 32
]);
->assertViewHasAll(tokenAndBalances(30, 31))
->dispatch('tokens-loaded')
->assertViewHasAll(tokenAndBalances(31, 32));
});

function tokenAndBalances($tokensCount, $balancesCount)
{
return [
'tokens' => fn ($tokens) => count($tokens) == $tokensCount,
'balances' => fn ($balances) => count($balances['prices']) == $balancesCount
&& count($balances['totals']) == $balancesCount
&& count($balances['ethereum']) == $balancesCount
&& count($balances['prices_eur']) == $balancesCount
&& count($balances['totals_eur']) == $balancesCount
];
}

0 comments on commit 0d05951

Please sign in to comment.