mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge remote-tracking branch 'origin/feat/assert-not-notified' into feat/assert-not-notified
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Livewire\Features\SupportTesting {
|
||||
|
||||
class Testable {
|
||||
public function assertNotified(Notification | string $notification = null): static {}
|
||||
|
||||
public function assertNotNotified(Notification | string $notification = null): static {}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,31 +63,23 @@ it('sends a notification', function () {
|
||||
);
|
||||
});
|
||||
```
|
||||
Conversely, you can test if a notification was not sent:
|
||||
|
||||
Conversely, you can assert that a notification was not sent:
|
||||
|
||||
```php
|
||||
use Filament\Notifications\Notification;
|
||||
use function Pest\Livewire\livewire;
|
||||
|
||||
it('does not send a notification', function () {
|
||||
livewire(CreatePost::class)
|
||||
->assertNotNotified();
|
||||
```
|
||||
You can test that a notification was not sent with a given title:
|
||||
```php
|
||||
it('does not send a notification', function () {
|
||||
livewire(CreatePost::class)
|
||||
->assertNotNotified('Unable to create post');
|
||||
});
|
||||
```
|
||||
Or with a given notification object:
|
||||
```php
|
||||
it('does not send a notification', function () {
|
||||
livewire(CreatePost::class)
|
||||
->assertNotNotified()
|
||||
// or
|
||||
->assertNotNotified('Unable to create post')
|
||||
// or
|
||||
->assertNotified(
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Unable to create post')
|
||||
->body('Something went wrong.'),
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
@@ -344,7 +344,7 @@ class Notification extends ViewComponent implements Arrayable
|
||||
return;
|
||||
}
|
||||
|
||||
if($expectedNotification instanceof Notification) {
|
||||
if ($expectedNotification instanceof Notification) {
|
||||
Assert::assertNotSame(
|
||||
$expectedNotification->title,
|
||||
$notification,
|
||||
|
||||
Reference in New Issue
Block a user