-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathUnblazeTest.php
More file actions
55 lines (45 loc) · 2.37 KB
/
UnblazeTest.php
File metadata and controls
55 lines (45 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use Livewire\Blaze\BladeRenderer;
use Livewire\Blaze\BladeService;
use Livewire\Blaze\Folder\Foldable;
use Livewire\Blaze\Support\ComponentSource;
use Livewire\Blaze\Parser\Parser;
test('compiles unblaze blocks', function () {
$input = '<x-foldable.input-unblaze name="address" />';
$node = app(Parser::class)->parse($input)[0];
$foldable = new Foldable($node, new ComponentSource(fixture_path('views/components/foldable/input-unblaze.blade.php')), app(BladeRenderer::class), app(BladeService::class));
expect($foldable->fold())->toEqualCollapsingWhitespace(
sprintf('<input %s >', join('', [
'<?php if (isset($scope)) $__scope = $scope; ?>',
'<?php $scope = array ( \'name\' => \'address\', ); ?>',
' {{ $errors->has($scope[\'name\']) }} ',
'<?php if (isset($__scope)) { $scope = $__scope; unset($__scope); } ?>'
]))
);
});
test('compiles nested unblaze blocks', function () {
$input = '<x-foldable.nested-input-unblaze />';
$node = app(Parser::class)->parse($input)[0];
$foldable = new Foldable($node, new ComponentSource(fixture_path('views/components/foldable/nested-input-unblaze.blade.php')), app(BladeRenderer::class), app(BladeService::class));
expect($foldable->fold())->toEqualCollapsingWhitespace(
sprintf('<div> <input %s ></div>', join('', [
'<?php if (isset($scope)) $__scope = $scope; ?>',
'<?php $scope = array ( \'name\' => \'address\', ); ?>',
' {{ $errors->has($scope[\'name\']) }} ',
'<?php if (isset($__scope)) { $scope = $__scope; unset($__scope); } ?>'
]))
);
});
test('folds dynamic attributes used inside unblaze directive', function () {
$input = '<x-foldable.input-unblaze :name="$field" />';
$node = app(Parser::class)->parse($input)[0];
$foldable = new Foldable($node, new ComponentSource(fixture_path('views/components/foldable/input-unblaze.blade.php')), app(BladeRenderer::class), app(BladeService::class));
expect($foldable->fold())->toEqualCollapsingWhitespace(
sprintf('<input %s >', join('', [
'<?php if (isset($scope)) $__scope = $scope; ?>',
'<?php $scope = array ( \'name\' => $field, ); ?>',
' {{ $errors->has($scope[\'name\']) }} ',
'<?php if (isset($__scope)) { $scope = $__scope; unset($__scope); } ?>'
]))
);
});