diff --git a/tests/Filament/UsernameComponentTest.php b/tests/Filament/UsernameComponentTest.php new file mode 100644 index 0000000..6793861 --- /dev/null +++ b/tests/Filament/UsernameComponentTest.php @@ -0,0 +1,31 @@ +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'); +});