Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebarlow committed Sep 4, 2024
1 parent cdfa6b7 commit 3e56d54
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/MegaphoneComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,45 @@
->assertSet('announcements', $user->readNotifications);
});

it('can mark all notifications as read', function () {
$this->actingAs(
$user = $this->createTestUser()
);

$this->createTestNotification(
$user,
\MBarlow\Megaphone\Types\General::class
);
$this->createTestNotification(
$user,
\MBarlow\Megaphone\Types\Important::class
);

$this->livewire(Megaphone::class)
->call('markAllRead')
->assertSet('unread', $user->announcements()->get()->whereNull('read_at'))
->assertSet('announcements', $user->readNotifications);
});

it('shows mark all as read if more than 1 notification', function () {
$this->actingAs(
$user = $this->createTestUser()
);

$this->createTestNotification(
$user,
\MBarlow\Megaphone\Types\General::class
);
$this->createTestNotification(
$user,
\MBarlow\Megaphone\Types\Important::class
);

$this->livewire(Megaphone::class)
->assertViewIs('megaphone::megaphone')
->assertSeeHtml('<button class="focus:outline-none text-sm leading-normal pt-8 hover:text-indigo-700" wire:click="markAllRead()">Mark all as read</button>');
});

it('can render the megaphone component with general notification', function () {
$this->actingAs(
$user = $this->createTestUser()
Expand Down

0 comments on commit 3e56d54

Please sign in to comment.