Skip to content

Commit 0ffd2df

Browse files
committed
Add failing test for using icon in a named slot
1 parent 5f38986 commit 0ffd2df

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<x-test-layout>
2+
<x-slot name="icon">
3+
<x-icon name="ph:eye" class="size-5" />
4+
</x-slot>
5+
Test
6+
</x-test-layout>

tests/Integration/View/IconComponentTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Tempest\View\IconConfig;
1515
use Tests\Tempest\Integration\FrameworkIntegrationTestCase;
1616

17+
use function Tempest\view;
18+
1719
final class IconComponentTest extends FrameworkIntegrationTestCase
1820
{
1921
protected function setUp(): void
@@ -183,4 +185,26 @@ public function test_with_dynamic_data(): void
183185
$rendered,
184186
);
185187
}
188+
189+
public function test_icon_renders_inside_named_slot_in_a_layout(): void
190+
{
191+
$this->registerViewComponent('x-test-layout', '<x-index><div><x-slot name="icon" /></div><x-slot /></x-index>');
192+
193+
$mockHttpClient = $this->createMock(HttpClient::class);
194+
$mockHttpClient
195+
->expects($this->exactly(1))
196+
->method('get')
197+
->with('https://api.iconify.design/ph/eye.svg')
198+
->willReturn(new GenericResponse(status: Status::OK, body: '<svg></svg>'));
199+
200+
$this->container->register(HttpClient::class, fn () => $mockHttpClient);
201+
202+
$view = view(__DIR__ . '/../../Fixtures/Views/view-with-icon-inside-named-slot.view.php');
203+
$html = $this->render($view);
204+
205+
$this->assertSame(
206+
'<html lang="en"><head><title></title></head><body><div><svg class="size-5"></svg></div>Test</body></html>',
207+
$html,
208+
);
209+
}
186210
}

0 commit comments

Comments
 (0)