Skip to content

Commit

Permalink
test: add UsernameComponentTest
Browse files Browse the repository at this point in the history
  • Loading branch information
alkrauss48 committed Dec 18, 2023
1 parent 38a0bb4 commit 78e763b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Filament/UsernameComponentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use App\Livewire\UsernameComponent;
use App\Models\User;

use function Pest\Livewire\livewire;

beforeEach(function () {
$this->user = User::factory()->create();

$this->actingAs($this->user);
});

it('can render component', function () {
livewire(UsernameComponent::class)
->assertStatus(200);
});

it('loads initial data', function () {
livewire(UsernameComponent::class)
->assertViewHas('data.username', $this->user->username);
});

it('updates the username', function () {
livewire(UsernameComponent::class)
->set('data.username', 'new-username')
->call('submit');

expect($this->user->refresh())
->username->toBe('new-username');
});

0 comments on commit 78e763b

Please sign in to comment.