Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Welte committed Jan 23, 2024
1 parent 3a35a43 commit b011ba3
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Countries/SwitzerlandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Countries\Switzerland;
use Spatie\Holidays\Exceptions\InvalidRegion;
use Spatie\Holidays\Holidays;

it('can calculate swiss holidays', function () {
Expand All @@ -16,3 +18,39 @@

expect(formatDates($holidays))->toMatchSnapshot();
});

it('can get swiss holidays for a specified region (zh)', function() {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$switzerland = new Switzerland(region: 'ch-zh');

$holidays = Holidays::for($switzerland)->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

it('throws an error when an invalid region is given', function () {
new Switzerland('ch-xx');
})->throws(InvalidRegion::class);

it('can translate swiss holidays', function() {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

$switzerland = new Switzerland(locale: 'fr');

$holidays = Holidays::for($switzerland)->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(formatDates($holidays))->toMatchSnapshot();
});

it('throws an error when an invalid locale is given', function () {
new Switzerland(locale: 'xx');
})->throws(InvalidRegion::class);

0 comments on commit b011ba3

Please sign in to comment.