-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #377 - refactor: refactored calendar month buttons - added dropdown with months * #377 - feat: added changing year from calendar buttons * #377 - fix: fixed icons * #377 - fix: linter fixes * #377 - fix: js linter node version update * #377 - fix: js linter node version update 2 * #377 - fix: js linter node version update 3 * #377 - feat: added tests
- Loading branch information
1 parent
54ad119
commit 1b1264b
Showing
8 changed files
with
326 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature; | ||
|
||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Tests\FeatureTestCase; | ||
use Toby\Models\User; | ||
use Toby\Models\YearPeriod; | ||
|
||
class CalendarTest extends FeatureTestCase | ||
{ | ||
use DatabaseMigrations; | ||
|
||
protected User $user; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->user = User::factory()->create(); | ||
} | ||
|
||
public function testUserCanChangeYearPeriodOnTheCalendar(): void | ||
{ | ||
$currentYearPeriod = YearPeriod::current(); | ||
$nextYearPeriod = YearPeriod::query() | ||
->create([ | ||
"year" => $currentYearPeriod->year + 1, | ||
]); | ||
|
||
$this->assertNotEquals($currentYearPeriod->year, $nextYearPeriod->year); | ||
|
||
$this->actingAs($this->user) | ||
->get("/calendar/january/$nextYearPeriod->year") | ||
->assertRedirect(); | ||
|
||
$selectedYearPeriod = YearPeriod::query()->where("id", session()->get("selected_year_period"))->first(); | ||
$this->assertEquals($selectedYearPeriod->year, $nextYearPeriod->year); | ||
} | ||
|
||
public function testUserCannotChangeYearPeriodIfYearPeriodDoesNotExist(): void | ||
{ | ||
$currentYearPeriod = YearPeriod::current(); | ||
|
||
$this->actingAs($this->user) | ||
->get("/calendar/january/" . ($currentYearPeriod->year + 1)) | ||
->assertStatus(404); | ||
|
||
$this->actingAs($this->user) | ||
->get("/calendar/january/$currentYearPeriod->year") | ||
->assertStatus(302); | ||
} | ||
|
||
public function testUserCanSeeCalendar(): void | ||
{ | ||
$this->actingAs($this->user) | ||
->get("/calendar") | ||
->assertOk(); | ||
} | ||
} |