From 49a9bcc4b4e123a74670be23e5668894012947e7 Mon Sep 17 00:00:00 2001 From: titantwentyone Date: Thu, 2 Nov 2023 12:45:29 +0000 Subject: [PATCH 1/3] chore: fix code style --- packages/notifications/src/Notification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/notifications/src/Notification.php b/packages/notifications/src/Notification.php index e6b2d9a6b9..2efe6ff789 100644 --- a/packages/notifications/src/Notification.php +++ b/packages/notifications/src/Notification.php @@ -346,7 +346,7 @@ class Notification extends ViewComponent implements Arrayable return; } - if($expectedNotification instanceof Notification) { + if ($expectedNotification instanceof Notification) { Assert::assertNotSame( $expectedNotification->title, $notification, From 8b59913c3df1cb3cd1671d9daea88d1f8e989b91 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sat, 4 Nov 2023 18:19:53 +0000 Subject: [PATCH 2/3] Update .stubs.php --- packages/notifications/.stubs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/notifications/.stubs.php b/packages/notifications/.stubs.php index 4778dd47ec..0db2e97f25 100644 --- a/packages/notifications/.stubs.php +++ b/packages/notifications/.stubs.php @@ -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 {} } From af6f7a65f1e8c15fb85c40907b70c340f4457791 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sat, 4 Nov 2023 18:21:05 +0000 Subject: [PATCH 3/3] Update 06-testing.md --- packages/notifications/docs/06-testing.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/notifications/docs/06-testing.md b/packages/notifications/docs/06-testing.md index b9fe5ce8ce..8cd1da6685 100644 --- a/packages/notifications/docs/06-testing.md +++ b/packages/notifications/docs/06-testing.md @@ -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.'), ); -}); ```