-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from lrljoe/AddClassAssertions
Add Class Assertions for Multiple Classes
- Loading branch information
Showing
4 changed files
with
307 additions
and
75 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
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,251 @@ | ||
<?php | ||
|
||
namespace LivewireDuskTestbench\Tests\Browser; | ||
|
||
use Livewire\Component; | ||
use Livewire\Livewire; | ||
use PHPUnit\Framework\AssertionFailedError; | ||
|
||
class DuskBrowserMixinTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function assert_see_in_order_macro_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul dusk="list"> | ||
<li>bob</li> | ||
<li>john</li> | ||
<li>bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertSeeInOrder('@list', ['bob', 'john', 'bill']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_see_in_order_macro_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul dusk="list"> | ||
<li>bob</li> | ||
<li>john</li> | ||
<li>bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertSeeInOrder('@list', ['john', 'bob', 'bill']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_is_visibile_in_container_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul style="height:10px" dusk="list"> | ||
<li style="height:10px" dusk="bob">bob</li> | ||
<li style="height:10px" dusk="john">john</li> | ||
<li style="height:10px" dusk="bill">bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertIsVisibleInContainer('@list', '@bob'); | ||
} | ||
|
||
/** @test */ | ||
public function assert_is_visibile_in_container_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul style="height:10px" dusk="list"> | ||
<li style="height:10px" dusk="bob">bob</li> | ||
<li style="height:10px" dusk="john">john</li> | ||
<li style="height:10px" dusk="bill">bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertIsVisibleInContainer('@list', '@john'); | ||
} | ||
|
||
/** @test */ | ||
public function assert_is_not_visibile_in_container_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul style="height:10px" dusk="list"> | ||
<li style="height:10px" dusk="bob">bob</li> | ||
<li style="height:10px" dusk="john">john</li> | ||
<li style="height:10px" dusk="bill">bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertIsNotVisibleInContainer('@list', '@john') | ||
->assertIsNotVisibleInContainer('@list', '@bill'); | ||
} | ||
|
||
/** @test */ | ||
public function assert_is_not_visibile_in_container_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<ul style="height:10px" dusk="list"> | ||
<li style="height:10px" dusk="bob">bob</li> | ||
<li style="height:10px" dusk="john">john</li> | ||
<li style="height:10px" dusk="bill">bill</li> | ||
</ul> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertIsNotVisibleInContainer('@list', '@bob'); | ||
} | ||
|
||
/** @test */ | ||
public function assert_has_classes_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="test other sample" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertHasClasses('@item', ['test', 'other']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_has_classes_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="test sample" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertHasClasses('@item', ['test', 'other']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_has_only_classes_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="test other" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertHasOnlyClasses('@item', ['test', 'other']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_has_only_classes_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="test other sample" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertHasOnlyClasses('@item', ['test', 'other']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_missing_classes_passes() | ||
{ | ||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="sample" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertMissingClasses('@item', ['test', 'other']); | ||
} | ||
|
||
/** @test */ | ||
public function assert_missing_classes_fails() | ||
{ | ||
$this->expectException(AssertionFailedError::class); | ||
|
||
Livewire::visit(new class extends Component | ||
{ | ||
public function render() | ||
{ | ||
return <<< 'HTML' | ||
<div> | ||
<p class="sample" dusk="item"></p> | ||
</div> | ||
HTML; | ||
} | ||
}) | ||
->assertMissingClasses('@item', ['test', 'sample']); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.