This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87c5b72
commit 851f7f3
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup> | ||
const emit = defineEmits(['trigger']) | ||
const trigger = () => { | ||
emit('trigger') | ||
} | ||
</script> | ||
|
||
<button @click="trigger">Trigger</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<x-layout> | ||
<script setup> | ||
const show = ref(false) | ||
function toggle() { | ||
show.value = !show.value | ||
} | ||
</script> | ||
|
||
<x-emit @trigger="toggle" /> | ||
|
||
<h2 v-if="show">Triggered</h2> | ||
</x-layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Tests\Browser; | ||
|
||
use Laravel\Dusk\Browser; | ||
use Tests\DuskTestCase; | ||
|
||
class EmitTest extends DuskTestCase | ||
{ | ||
/** @test */ | ||
public function it_can_bind_a_listener_to_an_emit_event() | ||
{ | ||
$this->browse(function (Browser $browser) { | ||
$browser->visit('/emit') | ||
->assertMissing('h2') | ||
->press('Trigger') | ||
->assertSeeIn('h2', 'Triggered'); | ||
}); | ||
} | ||
} |