assertSet('toasts', []) ->assertOk(); }); it('adds a success toast via toast event', function () { Livewire::test(Toaster::class) ->dispatch('toast', message: 'Link erstellt', type: 'success') ->assertCount('toasts', 1) ->assertSee('Link erstellt'); }); it('adds an error toast via toast event', function () { Livewire::test(Toaster::class) ->dispatch('toast', message: 'Fehler beim Speichern', type: 'error') ->assertCount('toasts', 1) ->assertSee('Fehler beim Speichern'); }); it('adds multiple toasts', function () { Livewire::test(Toaster::class) ->dispatch('toast', message: 'First', type: 'success') ->dispatch('toast', message: 'Second', type: 'error') ->assertCount('toasts', 2); }); it('dismisses a toast by id', function () { $toaster = Livewire::test(Toaster::class) ->dispatch('toast', message: 'Wird gelöscht', type: 'info'); $id = $toaster->get('toasts')[0]['id']; $toaster->call('dismiss', $id) ->assertCount('toasts', 0); }); it('toast has required fields', function () { $toaster = Livewire::test(Toaster::class) ->dispatch('toast', message: 'Test', type: 'warning'); $toast = $toaster->get('toasts')[0]; expect($toast)->toHaveKeys(['id', 'message', 'type', 'duration']) ->and($toast['message'])->toBe('Test') ->and($toast['type'])->toBe('warning') ->and($toast['duration'])->toBeInt()->toBeGreaterThan(0); });