Skip to content

Commit

Permalink
Test jobs responsible for fetching conversion rates
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Dec 26, 2023
1 parent 4744ca7 commit baaf9e5
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/Unit/Jobs/FetchConversionRatesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Tests\Unit\Jobs;

use App\Jobs\FetchConversionRate;
use App\Jobs\FetchConversionRates;
use App\Models\Currency;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;

class FetchConversionRatesTest extends TestCase
{
public function testWhetherIndividualJobsGetDispatched(): void
{
Queue::fake();

Queue::assertNothingPushed();

app()->call([new FetchConversionRates(), 'handle']);

Queue::assertPushed(FetchConversionRate::class, 0);

Currency::factory()
->create([
'name' => 'US Dollar',
'symbol' => '&dollar;',
'iso' => 'USD',
]);

Currency::factory()
->create([
'name' => 'Euro',
'symbol' => '&eur;',
'iso' => 'EUR',
]);

Currency::factory()
->create([
'name' => 'British Pound',
'symbol' => '&pound;',
'iso' => 'GBP',
]);

app()->call([new FetchConversionRates(), 'handle']);

Queue::assertPushed(FetchConversionRate::class, 3);
}
}

0 comments on commit baaf9e5

Please sign in to comment.