From 009126242406069a454834ca71dffbc9ff394b37 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sat, 15 Jan 2022 11:50:56 -0500 Subject: [PATCH] test: add new assertEmittedTo (#153) * test: add new assertEmittedTo * style: remove unused import --- .../UpdateGamePanel/ValidGameUpdateTest.php | 32 +++++-------------- .../ValidPlayerUpdateTest.php | 10 +++--- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/tests/Feature/Forms/UpdateGamePanel/ValidGameUpdateTest.php b/tests/Feature/Forms/UpdateGamePanel/ValidGameUpdateTest.php index 7aea9129..8dff104f 100644 --- a/tests/Feature/Forms/UpdateGamePanel/ValidGameUpdateTest.php +++ b/tests/Feature/Forms/UpdateGamePanel/ValidGameUpdateTest.php @@ -65,9 +65,7 @@ public function testValidResponseFromAllHaloDotApiServicesForABot(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -99,9 +97,7 @@ public function testValidResponseFromAllHaloDotApiServicesForUnranked(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -128,9 +124,7 @@ public function testValidResponseFromAllHaloDotApiServices(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -159,9 +153,7 @@ public function testValidResponseFromAllHaloDotApiServicesAsSlayer(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -190,9 +182,7 @@ public function testValidResponseFromAllHaloDotApiServicesAsCtf(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -221,9 +211,7 @@ public function testValidResponseFromAllHaloDotApiServicesAsOddball(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -252,9 +240,7 @@ public function testValidResponseFromAllHaloDotApiServicesAsStrongholds(): void ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Queue::assertPushed(PullAppearance::class); } @@ -286,9 +272,7 @@ public function testValidResponseFromAllHaloDotApiServicesIncludingAppearance(): ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Game updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo('game-page', '$refresh'); Bus::assertDispatchedTimes(PullXuid::class, 2); } diff --git a/tests/Feature/Forms/UpdatePlayerPanel/ValidPlayerUpdateTest.php b/tests/Feature/Forms/UpdatePlayerPanel/ValidPlayerUpdateTest.php index 30213293..e25baca3 100644 --- a/tests/Feature/Forms/UpdatePlayerPanel/ValidPlayerUpdateTest.php +++ b/tests/Feature/Forms/UpdatePlayerPanel/ValidPlayerUpdateTest.php @@ -270,9 +270,7 @@ public function testValidResponseFromAllHaloDotApiServices(string $type, string ]) ->assertViewHas('color', 'is-success') ->assertViewHas('message', 'Profile updated!') - - // TODO - I cannot assert to a specific component - https://github.com/livewire/livewire/discussions/4298 - ->assertEmitted('$refresh'); + ->assertEmittedTo($event, '$refresh'); } public function validPageDataProvider(): array @@ -280,15 +278,15 @@ public function validPageDataProvider(): array return [ 'overview' => [ 'type' => PlayerTab::OVERVIEW, - 'event' => OverviewPage::class, + 'event' => 'overview-page', ], 'competitive' => [ 'type' => PlayerTab::COMPETITIVE, - 'event' => CompetitivePage::class, + 'event' => 'competitive-page', ], 'matches' => [ 'type' => PlayerTab::MATCHES, - 'event' => GameHistoryTable::class, + 'event' => 'game-history-table', ] ]; }