Skip to content

Commit 42f15af

Browse files
committed
add livewire test case
1 parent d1037bf commit 42f15af

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/FileEditor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function process(string $content, Collection $grammar, string $method): s
6161
});
6262

6363

64-
// eval(\Psy\sh());
6564

6665
return $file->output();
6766
}

tests/FileEditorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use MagicTest\MagicTest\FileEditor;
66
use MagicTest\MagicTest\Grammar\Click;
7+
use MagicTest\MagicTest\Grammar\Fill;
78
use MagicTest\MagicTest\Grammar\See;
89

910
class FileEditorTest extends TestCase
@@ -75,6 +76,29 @@ public function it_properly_adds_new_actions_to_a_test()
7576
$this->assertEquals($expectedOutput, $processedText);
7677
}
7778

79+
/** @test */
80+
public function it_properly_adds_fills_to_a_livewire_test()
81+
{
82+
$input = file_get_contents(__DIR__ . '/fixtures/ExampleTestWithContentAndLivewireInput.example');
83+
$expectedOutput = file_get_contents(__DIR__ . '/fixtures/ExampleTestWithContentAndLivewireOutput.example');
84+
85+
$grammar = collect([
86+
new Fill('', 'name', [
87+
'text' => "'Mateus'",
88+
], [], 'button', [
89+
'isLivewire' => true,
90+
]),
91+
new Fill('', 'email', [
92+
'text' => "'mateus@mateusguimaraes.com'",
93+
], [], 'button', [
94+
'isLivewire' => true,
95+
]),
96+
]);
97+
98+
$processedText = (new FileEditor)->process($input, $grammar, 'testBasicExample');
99+
$this->assertEquals($expectedOutput, $processedText);
100+
}
101+
78102
/** @test */
79103
public function it_finishes_a_test_using_the_helper()
80104
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Tests\Browser;
4+
5+
use Tests\DuskTestCase;
6+
use Laravel\Dusk\Browser;
7+
use MagicTest\MagicTest\MagicTest;
8+
use MagicTest\MagicTest\MagicTestManager;
9+
use Illuminate\Foundation\Testing\DatabaseMigrations;
10+
11+
class ExampleTest extends DuskTestCase
12+
{
13+
/**
14+
* A basic browser test example.
15+
*
16+
* @return void
17+
*/
18+
public function testBasicExample()
19+
{
20+
$this->browse(function (Browser $browser) {
21+
$browser->visit('/')
22+
->assertSee('Laravel')
23+
->clickLink('Log in')
24+
->magic();
25+
});
26+
}
27+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Tests\Browser;
4+
5+
use Tests\DuskTestCase;
6+
use Laravel\Dusk\Browser;
7+
use MagicTest\MagicTest\MagicTest;
8+
use MagicTest\MagicTest\MagicTestManager;
9+
use Illuminate\Foundation\Testing\DatabaseMigrations;
10+
11+
class ExampleTest extends DuskTestCase
12+
{
13+
/**
14+
* A basic browser test example.
15+
*
16+
* @return void
17+
*/
18+
public function testBasicExample()
19+
{
20+
$this->browse(function (Browser $browser) {
21+
$browser->visit('/')
22+
->assertSee('Laravel')
23+
->clickLink('Log in')
24+
->pause(500)
25+
->type('name', 'Mateus')
26+
->pause(500)
27+
->type('email', 'mateus@mateusguimaraes.com')
28+
->pause(500)
29+
->magic();
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)