Skip to content

Instantly share code, notes, and snippets.

@claytonrcarter
Created February 24, 2022 17:42
Show Gist options
  • Save claytonrcarter/1776662aa096da7eefa591af6bf17e99 to your computer and use it in GitHub Desktop.
Save claytonrcarter/1776662aa096da7eefa591af6bf17e99 to your computer and use it in GitHub Desktop.
❯ npm test tests/fixtures.test.ts
> @ryangjchandler/prettier-plugin-blade@ test /Users/crcarter/src/prettier-plugin-blade
> jest "tests/fixtures.test.ts"
FAIL tests/fixtures.test.ts
✕ comment/basic.blade.php (262 ms)
✕ comment/escaped.blade.php (6 ms)
✕ components/component-directive.blade.php (24 ms)
✓ components/component-namespace-tag-no-closing.blade.php (5 ms)
✕ components/component-namespace-tag.blade.php (10 ms)
✓ components/component-tag-no-closing.blade.php (6 ms)
✕ components/component-tag.blade.php (8 ms)
✓ directive/auth-directive.blade.php (11 ms)
✓ directive/csrf-directive.blade.php (9 ms)
✕ directive/custom-if-directive.blade.php (16 ms)
✓ directive/empty-directive.blade.php (11 ms)
✕ directive/error-directive.blade.php (20 ms)
✓ directive/escaped-directive-parameters.blade.php (7 ms)
✓ directive/escaped-directive.blade.php (6 ms)
✓ directive/guest-directive.blade.php (8 ms)
✓ directive/if-else-directive.blade.php (25 ms)
✓ directive/inject.blade.php (9 ms)
✓ directive/isset-directive.blade.php (13 ms)
✓ directive/method-directive.blade.php (10 ms)
✓ directive/pair-directive-starting-on-line.blade.php (9 ms)
✓ directive/prepend-directive.blade.php (10 ms)
✓ directive/push-directive.blade.php (9 ms)
✓ directive/stack-directive.blade.php (8 ms)
✕ directive/superfluous-spaces-directive.blade.php (17 ms)
✓ directive/unless-directive.blade.php (10 ms)
✕ directive/yield-directive.blade.php (6 ms)
✓ echo/escaped.blade.php (4 ms)
✕ echo/raw.blade.php (7 ms)
✕ echo/simple.blade.php (9 ms)
✓ echo/verbatim.blade.php (9 ms)
✓ html/pure-html.blade.php (7 ms)
✓ html/pure-html.html (6 ms)
✕ php-tags/php-echo-tags.blade.php (3 ms)
✕ php-tags/php-long-tags.blade.php (4 ms)
✕ php-tags/php-on-same-line.blade.php (5 ms)
✕ php-tags/php-on-same-split-line.blade.php (2 ms)
✕ php-tags/php-with-blade-directive-in-string.blade.php (5 ms)
✕ php-tags/php-with-html-in-string.blade.php (3 ms)
✕ php-tags/php-wrapper-with-extra-closing.blade.php (4 ms)
✕ should test (13 ms)
● comment/basic.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 3
- <h1>Here's some very nice text {{-- This is actually not that nice --}}</h1>
+ <h1>
+ Here's some very nice text {{-- This is actually not that nice --}}
+ </h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● comment/escaped.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 3
- <h1>Here's some very nice text @{{-- This is actually not that nice --}}</h1>
+ <h1>
+ Here's some very nice text @{{-- This is actually not that nice --}}
+ </h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● components/component-directive.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 8
+ Received + 4
@component('view')
- @slot('name', 'value')
+ @slot('name', 'value')
- @slot('name2', true)
+ @slot('name2', true)
- @slot('name3')
+ @slot('name3')
- <div>Name3 Slot</div>
- @endslot
-
- <div>Default Slot</div>
- @endcomponent
+ <div>Name3 Slot</div>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● components/component-namespace-tag.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 14
+ Received + 11
- <x-namespace::view x="X" :y="'Y'">
+ <x-view x="X" :y="'Y'">
- <x-slot name="Name">
+ <x-slot name="Name">
- <div>Named Slot</div>
- </x-slot>
+ <div>Named Slot</div></x-slot>
- <x-slot:trigger>
+ <x-slot:trigger>
- <div>Trigger Slot</div>
+ <div>Trigger Slot</div>
- </x-slot:trigger>
-
- <x-slot:footer>
+ </x-slot:trigger><x-slot:footer>
- <div>Footer Slot</div>
+ <div>Footer Slot</div>
- </x-slot>
+ </x-slot>
-
- <div>Default Slot</div>
+ <div>
+ Default Slot</div>
- </x-namespace::view>
+ </x-view>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● components/component-tag.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 13
+ Received + 10
<x-view x="X" :y="'Y'">
- <x-slot name="Name">
+ <x-slot name="Name">
- <div>Named Slot</div>
- </x-slot>
+ <div>Named Slot</div></x-slot>
- <x-slot:trigger>
+ <x-slot:trigger>
- <div>Trigger Slot</div>
+ <div>Trigger Slot</div>
- </x-slot:trigger>
-
- <x-slot:footer>
+ </x-slot:trigger><x-slot:footer>
- <div>Footer Slot</div>
+ <div>Footer Slot</div>
- </x-slot>
+ </x-slot>
-
- <div>Default Slot</div>
+ <div>
+ Default Slot</div>
- </x-view>
+ </x-view>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● directive/custom-if-directive.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 9
+ Received + 2
@disk('local')
- local!
+ local!
@elsedisk('s3')
- s3!
- @else
- not sure?
- @enddisk
-
- @unlessdisk('local')
- something not local
- @enddisk
+ s3!
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● directive/error-directive.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 8
<label for="title">Post Title</label>
- <input id="title" type="text" class="@error('title') is-invalid @enderror">
+ <input
+ id="title"
+ type="text"
+ class="@error('title') is-invalid @enderror"
+ />
@error('title')
- <div class="alert alert-danger">{{ $message }}</div>
+ <div class="alert alert-danger">
+ {{ $message }}
+ </div>
@enderror
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● directive/superfluous-spaces-directive.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 2
<h1>
@if(true)
goood
@endif
- @if("test" === "test")
+ @if("test"
+ === "test")
baaad
@endif
</h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● directive/yield-directive.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 2
- @yield('content', 'Default content')
+ @yield('content',
+ 'Default content')
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● echo/raw.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 4
- <h1>Here's some very poorly formatted {!! $rawEchos !!}</h1>
+ <h1>
+ Here's some very poorly formatted
+ {!! $rawEchos !!}
+ </h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● echo/simple.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 4
- <h1>Poorly formatted {{ 'html' }} with weird {{ $echoParts + 1 / $insideOfIt }}</h1>
+ <h1>
+ Poorly formatted {{ 'html' }} with weird
+ {{ $echoParts + 1 / $insideOfIt }}
+ </h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-echo-tags.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
- {!! "Cool stuff" !!}
+ <?= "Cool stuff" ?>
<h1>Awesome</h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-long-tags.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 4
+ Received + 2
- @php
+ <?php
-
echo "long way there";
-
- @endphp
+ ?>
<h1>Awesome</h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-on-same-line.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 5
+ Received + 3
- @php
-
- echo "Some to be happy about";
+ <?php echo "Some to be happy about";
-
- @endphp
+ ?>
+
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-on-same-split-line.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 5
+ Received + 2
- @php
-
- echo "Some to be happy about";
-
- @endphp
+ <?php echo "Some to be happy about"; ?>
+
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-with-blade-directive-in-string.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 4
+ Received + 2
- @php
-
+ <?
echo "something cool @csrf"
-
- @endphp
+ ?>
<h1>Awesome</h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-with-html-in-string.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 6
+ Received + 5
- @php
-
+ <?
- echo "<title>Some to be happy about</title>";
-
- @endphp
+ echo "<title>Some to be happy about</title>"
+ ?>
- <h1>Awesome</h1>
+ <h1>Awesome
+ </h1>
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● php-tags/php-wrapper-with-extra-closing.blade.php
expect(received).toEqual(expected) // deep equality
- Expected - 5
+ Received + 2
- @php
-
- echo "Some to be ?>happy about";
-
- @endphp
+ <?php echo "Some to be ?>happy about"; ?>
+
14 | .map((part) => part.trimStart());
15 |
> 16 | expect(format(original)).toEqual(expected);
| ^
17 | });
18 |
19 |
at tests/fixtures.test.ts:16:30
● should test
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 2
<h1>
@if(true)
goood
@endif
- @if("test" === "test")
+ @if("test"
+ === "test")
baaad
@endif
</h1>
23 | .map((part) => part.trimStart());
24 |
> 25 | expect(format(original)).toEqual(expected);
| ^
26 | });
at Object.<anonymous> (tests/fixtures.test.ts:25:30)
Test Suites: 1 failed, 1 total
Tests: 19 failed, 21 passed, 40 total
Snapshots: 0 total
Time: 2.827 s, estimated 4 s
Ran all test suites matching /tests\/fixtures.test.ts/i.
npm ERR! Test failed. See above for more details.
❯ npm test tests/parser.test.ts
> @ryangjchandler/prettier-plugin-blade@ test /Users/crcarter/src/prettier-plugin-blade
> jest "tests/parser.test.ts"
FAIL tests/parser.test.ts
✓ should parse ast for pair directives (5 ms)
✕ should parse ast for pair directives with children (266 ms)
✓ should parse ast for directive (1 ms)
✕ should parse ast for multiple directive (4 ms)
✕ should parse ast @if @endif directive block (4 ms)
✕ should parse ast @if @else @endif directive block (3 ms)
✕ should parse ast @if @elseif @else @endif directive block (4 ms)
✕ should parse ast @if block with multiple elseif (4 ms)
✓ should parse ast verbatim block (1 ms)
✎ todo should parse ast for par directive with child pair directive
✎ todo should parse literal only
● should parse ast for pair directives with children
expect(received).toBe(expected) // Object.is equality
- Expected - 0
+ Received + 1
I am god!
+
46 | expect(directivePairNode.open.directive).toBe("auth");
47 | expect(directivePairNode.children).toHaveLength(1);
> 48 | expect(directivePairNode.children[0].toString()).toBe("I am god!");
| ^
49 | expect(directivePairNode.close.directive).toBe("endauth");
50 | });
51 |
at Object.<anonymous> (tests/parser.test.ts:48:54)
● should parse ast for multiple directive
expect(received).toBe(expected) // Object.is equality
Expected: " "
Received: ""
71 |
72 | const literal = ast.children[1] as LiteralNode;
> 73 | expect(literal.toString()).toBe(" ");
| ^
74 |
75 | const csrfDirective = ast.children[2] as DirectiveNode;
76 | expect(csrfDirective.directive).toBe("csrf");
at Object.<anonymous> (tests/parser.test.ts:73:32)
● should parse ast @if @endif directive block
expect(received).toBe(expected) // Object.is equality
- Expected - 1
+ Received + 2
- cool
+ cool
+
87 | expect(ifBlockNode.open.directive).toBe("if");
88 | expect(ifBlockNode.children).toHaveLength(1);
> 89 | expect(ifBlockNode.children[0].toString()).toBe(" cool ");
| ^
90 | expect(ifBlockNode.close.directive).toBe("endif");
91 | });
92 |
at Object.<anonymous> (tests/parser.test.ts:89:48)
● should parse ast @if @else @endif directive block
expect(received).toBe(expected) // Object.is equality
- Expected - 1
+ Received + 2
- nice
+ nice
+
100 | expect(ifBlockNode.open.directive).toBe("if");
101 | expect(ifBlockNode.children).toHaveLength(1);
> 102 | expect(ifBlockNode.children[0].toString()).toBe(" nice ");
| ^
103 |
104 | const elseBlockNode = ifBlockNode.elseBlock;
105 | expect(elseBlockNode?.elseDirective.directive).toBe("else");
at Object.<anonymous> (tests/parser.test.ts:102:48)
● should parse ast @if @elseif @else @endif directive block
expect(received).toBe(expected) // Object.is equality
- Expected - 1
+ Received + 2
- nice
+ nice
+
119 | expect(ifBlockNode.open.directive).toBe("if");
120 | expect(ifBlockNode.children).toHaveLength(1);
> 121 | expect(ifBlockNode.children[0].toString()).toBe(" nice ");
| ^
122 |
123 | expect(ifBlockNode.elseIfBlocks).toHaveLength(1);
124 | const elseIfBlockNode = ifBlockNode.elseIfBlocks[0];
at Object.<anonymous> (tests/parser.test.ts:121:48)
● should parse ast @if block with multiple elseif
expect(received).toBe(expected) // Object.is equality
- Expected - 1
+ Received + 2
- snake
+ snake
+
145 | expect(ifBlockNode.open.directive).toBe("if");
146 | expect(ifBlockNode.children).toHaveLength(1);
> 147 | expect(ifBlockNode.children[0].toString()).toBe(" snake ");
| ^
148 |
149 | expect(ifBlockNode.elseIfBlocks).toHaveLength(2);
150 | const elseIfBlockNodeA = ifBlockNode.elseIfBlocks[0];
at Object.<anonymous> (tests/parser.test.ts:147:48)
Test Suites: 1 failed, 1 total
Tests: 6 failed, 2 todo, 3 passed, 11 total
Snapshots: 0 total
Time: 2.574 s, estimated 3 s
Ran all test suites matching /tests\/parser.test.ts/i.
npm ERR! Test failed. See above for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment