32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\View\Form;
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ViewErrorBag;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('renders component', function ($component, $params, $expected = '', $notExpected = '') {
|
|
View::share(['errors' => new ViewErrorBag()]);
|
|
$rendered = Blade::render($component, $params);
|
|
|
|
if ($expected) {
|
|
expect($rendered)->toContain($expected);
|
|
}
|
|
|
|
if ($notExpected) {
|
|
expect($rendered)->not()->toContain($notExpected);
|
|
}
|
|
})->with([
|
|
'php string' => ['<x-form::lever name="name" label="the label" />', [], 'x-text="`the label`"'],
|
|
'php string with escaping' => ['<x-form::lever name="name" label="the <label>" />', [], 'x-text="`the <label>`"'],
|
|
'php string with var' => ['<x-form::lever name="name" :label="$label" />', ['label' => 'the <label>'], 'x-text="`the <label>`"'],
|
|
'js plain string' => ['<x-form::lever name="name" ::label="post.name" />', [], 'x-text="post.name"'],
|
|
'js plain string with <' => ['<x-form::lever name="name" ::label="post.<name" />', [], 'x-text="post.<name"'],
|
|
'raw id' => ['<x-form::lever name="name" ::id="post.id" />', [], ':id="post.id"'],
|
|
'raw id with for' => ['<x-form::lever name="name" ::id="post.id" />', [], ':for="post.id"'],
|
|
]);
|