mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
chore: refactor PluginInlineTemplatesTest to Pest
This commit is contained in:
parent
a129c71d79
commit
2eee024b36
1 changed files with 107 additions and 122 deletions
|
|
@ -1,19 +1,11 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Plugin;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PluginInlineTemplatesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
public function test_plugin_with_inline_templates(): void
|
||||
{
|
||||
test('renders plugin with inline templates', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'name' => 'Test Plugin',
|
||||
'markup_language' => 'liquid',
|
||||
|
|
@ -39,7 +31,6 @@ class PluginInlineTemplatesTest extends TestCase
|
|||
|
||||
{% template title_bar %}
|
||||
<div class="title_bar">
|
||||
<img class="image" src="https://res.jwq.lol/img/lumon.svg">
|
||||
<span class="title">{{ trmnl.plugin_settings.instance_name }}</span>
|
||||
<span class="instance">{{ instance }}</span>
|
||||
</div>
|
||||
|
|
@ -77,10 +68,9 @@ LIQUID
|
|||
$this->assertStringContainsString('Test Plugin', $result);
|
||||
$this->assertStringContainsString('Please try to enjoy each fact equally', $result);
|
||||
$this->assertStringContainsString('class="view view--full"', $result);
|
||||
}
|
||||
});
|
||||
|
||||
public function test_plugin_with_inline_templates_using_with_syntax(): void
|
||||
{
|
||||
test('renders plugin with inline templates using with syntax', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'name' => 'Test Plugin',
|
||||
'markup_language' => 'liquid',
|
||||
|
|
@ -144,10 +134,9 @@ LIQUID
|
|||
$this->assertStringContainsString('Test Plugin', $result);
|
||||
$this->assertStringContainsString('Please try to enjoy each fact equally', $result);
|
||||
$this->assertStringContainsString('class="view view--full"', $result);
|
||||
}
|
||||
});
|
||||
|
||||
public function test_plugin_with_simple_inline_template(): void
|
||||
{
|
||||
test('renders plugin with simple inline template', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'markup_language' => 'liquid',
|
||||
'render_markup' => <<<'LIQUID'
|
||||
|
|
@ -171,10 +160,9 @@ LIQUID
|
|||
$this->assertStringContainsString('Hello World', $result);
|
||||
$this->assertStringContainsString('This is a test', $result);
|
||||
$this->assertStringContainsString('class="simple"', $result);
|
||||
}
|
||||
});
|
||||
|
||||
public function test_plugin_with_find_by_filter(): void
|
||||
{
|
||||
test('renders plugin with liquid filter find_by', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'markup_language' => 'liquid',
|
||||
'render_markup' => <<<'LIQUID'
|
||||
|
|
@ -204,10 +192,9 @@ LIQUID
|
|||
$this->assertStringContainsString('Ryan', $result);
|
||||
$this->assertStringContainsString('Age: 35', $result);
|
||||
$this->assertStringContainsString('class="user"', $result);
|
||||
}
|
||||
});
|
||||
|
||||
public function test_plugin_with_find_by_filter_and_fallback(): void
|
||||
{
|
||||
test('renders plugin with liquid filter find_by and fallback', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'markup_language' => 'liquid',
|
||||
'render_markup' => <<<'LIQUID'
|
||||
|
|
@ -227,10 +214,9 @@ LIQUID
|
|||
|
||||
// Should return the fallback value
|
||||
$this->assertStringContainsString('Not Found', $result);
|
||||
}
|
||||
});
|
||||
|
||||
public function test_plugin_with_group_by_filter(): void
|
||||
{
|
||||
test('renders plugin with liquid filter group_by', function () {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'markup_language' => 'liquid',
|
||||
'render_markup' => <<<'LIQUID'
|
||||
|
|
@ -251,5 +237,4 @@ LIQUID
|
|||
// Should output JSON representation of grouped data
|
||||
$this->assertStringContainsString('"35":[{"name":"Ryan","age":35}]', $result);
|
||||
$this->assertStringContainsString('"29":[{"name":"Sara","age":29},{"name":"Jimbob","age":29}]', $result);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue