Skip to content

Commit

Permalink
test: add new assertEmittedTo (#153)
Browse files Browse the repository at this point in the history
* test: add new assertEmittedTo

* style: remove unused import
  • Loading branch information
iBotPeaches authored Jan 15, 2022
1 parent 362060f commit 0091262
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
32 changes: 8 additions & 24 deletions tests/Feature/Forms/UpdateGamePanel/ValidGameUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 4 additions & 6 deletions tests/Feature/Forms/UpdatePlayerPanel/ValidPlayerUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,23 @@ 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
{
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',
]
];
}
Expand Down

0 comments on commit 0091262

Please sign in to comment.