Merge remote-tracking branch 'origin/feat/assert-not-notified' into feat/assert-not-notified

This commit is contained in:
Tim Smith
2023-11-04 18:36:13 +00:00
3 changed files with 9 additions and 16 deletions
+1
View File
@@ -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 {}
}
+7 -15
View File
@@ -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.'),
);
});
```
+1 -1
View File
@@ -344,7 +344,7 @@ class Notification extends ViewComponent implements Arrayable
return;
}
if($expectedNotification instanceof Notification) {
if ($expectedNotification instanceof Notification) {
Assert::assertNotSame(
$expectedNotification->title,
$notification,