-
-
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 #4 from kblais/allow-both-string-and-name-type
- Loading branch information
Showing
12 changed files
with
152 additions
and
41 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 was deleted.
Oops, something went wrong.
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,86 @@ | ||
<?php | ||
|
||
namespace Enflow\LivewireTwig\Test; | ||
|
||
use Livewire\Component; | ||
use Livewire\Livewire; | ||
|
||
class RenderTest extends TestCase | ||
{ | ||
public function test_name_type_component_correctly_renders() | ||
{ | ||
Livewire::component('counter', Counter::class); | ||
|
||
$rendered = view('name-type-test')->render(); | ||
|
||
$this->assertStringContainsString('[wire\:loading]', $rendered); // Styles | ||
$this->assertStringContainsString('window.livewire', $rendered); // Scripts | ||
$this->assertStringContainsString('increment', $rendered); // Counter component | ||
$this->assertStringContainsString('Lorem ipsum!', $rendered); // Counter component title | ||
} | ||
|
||
public function test_string_type_component_correctly_renders() | ||
{ | ||
Livewire::component('counter', Counter::class); | ||
|
||
$rendered = view('string-type-test')->render(); | ||
|
||
$this->assertStringContainsString('[wire\:loading]', $rendered); // Styles | ||
$this->assertStringContainsString('window.livewire', $rendered); // Scripts | ||
$this->assertStringContainsString('increment', $rendered); // Counter component | ||
$this->assertStringContainsString('Lorem ipsum!', $rendered); // Counter component title | ||
} | ||
|
||
public function test_nested_component_correctly_renders() | ||
{ | ||
Livewire::component('table', Table::class); | ||
Livewire::component('table.row', TableRow::class); | ||
Livewire::component('dashed-counter', Counter::class); | ||
|
||
$rendered = view('nested-test')->render(); | ||
|
||
$this->assertStringContainsString('increment', $rendered); | ||
$this->assertStringContainsString('Foo', $rendered); | ||
$this->assertStringContainsString('Bar', $rendered); | ||
} | ||
|
||
public function test_invalid_type_throws_exception() | ||
{ | ||
$this->expectException(\ErrorException::class); | ||
$this->expectExceptionMessage('Unexpected token "number" of value "63" ("name" or "string" expected).'); | ||
Livewire::component('counter', Counter::class); | ||
|
||
$rendered = view('invalid-type-test')->render(); | ||
} | ||
} | ||
|
||
class Counter extends Component | ||
{ | ||
public $count = 3; | ||
public $title = null; | ||
|
||
public function render() | ||
{ | ||
return view('components.counter'); | ||
} | ||
} | ||
|
||
class Table extends Component | ||
{ | ||
public $elements; | ||
|
||
public function render() | ||
{ | ||
return view('components.table'); | ||
} | ||
} | ||
|
||
class TableRow extends Component | ||
{ | ||
public $element; | ||
|
||
public function render() | ||
{ | ||
return view('components.table.row'); | ||
} | ||
} |
File renamed without changes.
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,5 @@ | ||
<table> | ||
{% for element in elements %} | ||
{% livewire 'table.row' with { 'element': element } %} | ||
{% endfor %} | ||
</table> |
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,4 @@ | ||
<tr> | ||
<td>{{ element.id }}</td> | ||
<td>{{ element.name }}</td> | ||
</tr> |
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,5 @@ | ||
{% extends 'layout' %} | ||
|
||
{% block content %} | ||
{% livewire 63 %} | ||
{% endblock %} |
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
{{ livewireStyles() }} | ||
|
||
{% livewire counter %} | ||
|
||
{% livewire counter with {'count': 3} %} | ||
|
||
{% livewire counter with {'count': 3, 'title': 'Lorem ipsum!'} %} | ||
{% block content %}{% endblock %} | ||
|
||
{{ livewireScripts() }} |
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 @@ | ||
{% extends 'layout' %} | ||
|
||
{% block content %} | ||
{% livewire counter %} | ||
|
||
{% livewire counter with {'count': 3} %} | ||
|
||
{% livewire counter with {'count': 3, 'title': 'Lorem ipsum!'} %} | ||
{% endblock %} |
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,12 @@ | ||
{% extends 'layout' %} | ||
|
||
{% set elements = [ | ||
{'id': 1, 'name': 'Foo'}, | ||
{'id': 2, 'name': 'Bar'}, | ||
] %} | ||
|
||
{% block content %} | ||
{% livewire 'dashed-counter' %} | ||
|
||
{% livewire 'table' with {'elements' : elements} %} | ||
{% endblock %} |
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 @@ | ||
{% extends 'layout' %} | ||
|
||
{% block content %} | ||
{% livewire 'counter' %} | ||
|
||
{% livewire 'counter' with {'count': 3} %} | ||
|
||
{% livewire 'counter' with {'count': 3, 'title': 'Lorem ipsum!'} %} | ||
{% endblock %} |