From f9e72506e7ebe0435a98a3a022ad9915a0f3a4b0 Mon Sep 17 00:00:00 2001 From: Ronald Chaplin <169922+t73biz@users.noreply.github.com> Date: Sun, 14 Jul 2024 03:20:53 -0500 Subject: [PATCH] lwb-183 Implement embedded_content embed component (#184) --- .../views/embedded_content/embed.blade.php | 3 + src/Components/EmbeddedContent/Embed.php | 41 ++++++ tests/Feature/EmbeddedContent/EmbedTest.php | 119 ++++++++++++++++++ .../Components/EmbeddedContent/MyEmbed.php | 7 ++ 4 files changed, 170 insertions(+) create mode 100644 resources/views/embedded_content/embed.blade.php create mode 100644 src/Components/EmbeddedContent/Embed.php create mode 100644 tests/Feature/EmbeddedContent/EmbedTest.php create mode 100644 tests/TestSupport/Components/EmbeddedContent/MyEmbed.php diff --git a/resources/views/embedded_content/embed.blade.php b/resources/views/embedded_content/embed.blade.php new file mode 100644 index 00000000..6808c0e1 --- /dev/null +++ b/resources/views/embedded_content/embed.blade.php @@ -0,0 +1,3 @@ + + {{ $slot }} + diff --git a/src/Components/EmbeddedContent/Embed.php b/src/Components/EmbeddedContent/Embed.php new file mode 100644 index 00000000..d1dce10d --- /dev/null +++ b/src/Components/EmbeddedContent/Embed.php @@ -0,0 +1,41 @@ +setGlobalAttributes(); + } + + /** + * Standard render function + */ + public function render(): Application|ContractedApplication|ContractedView|Factory|View + { + return view( + 'lw-bits::embedded_content.embed', + [ + 'globalAttributes' => $this->getGlobalAttributes(), + 'slot' => '', + ] + ); + } +} diff --git a/tests/Feature/EmbeddedContent/EmbedTest.php b/tests/Feature/EmbeddedContent/EmbedTest.php new file mode 100644 index 00000000..3edab152 --- /dev/null +++ b/tests/Feature/EmbeddedContent/EmbedTest.php @@ -0,0 +1,119 @@ +assertStatus(200); +}); + +it('can render with accesskey', function () { + Livewire::test(MyEmbed::class, ['accessKey' => true]) + ->assertSee('accesskey'); +}); + +it('can render with autocapitalize', function () { + Livewire::test(MyEmbed::class, ['autoCapitalize' => true]) + ->assertSee('autocapitalize'); +}); + +it('can render with autofocus', function () { + Livewire::test(MyEmbed::class, ['autoFocus' => true]) + ->assertSee('autofocus'); +}); + +it('can render with contenteditable', function () { + Livewire::test(MyEmbed::class, ['contentEditable' => true]) + ->assertSee('contenteditable'); +}); + +it('can render with css classes', function () { + Livewire::test(MyEmbed::class, ['cssClasses' => ['class1', 'class2']]) + ->assertSee('class="class1 class2"', false); +}); + +it('can render with data-*', function () { + Livewire::test(MyEmbed::class, ['data' => ['name' => 'main-embed']]) + ->assertSee('data-name="main-embed"', false); +}); + +it('can render with dir', function () { + Livewire::test(MyEmbed::class, ['direction' => 'rtl']) + ->assertSee('dir="rtl"', false); +}); + +it('can render with draggable', function () { + Livewire::test(MyEmbed::class, ['draggable' => true]) + ->assertSee('draggable'); +}); + +it('can render with enterkeyhint', function () { + Livewire::test(MyEmbed::class, ['enterKeyHint' => 'enter']) + ->assertSee('enterkeyhint="enter"', false); +}); + +it('can render with hidden', function () { + Livewire::test(MyEmbed::class, ['hidden' => true]) + ->assertSee('hidden'); +}); + +it('can render with id', function () { + Livewire::test(MyEmbed::class, ['id' => 'main-embed']) + ->assertSee('id="main-embed"', false); +}); + +it('can render with language', function () { + Livewire::test(MyEmbed::class, ['language' => 'en']) + ->assertSee('lang="en"', false); +}); + +it('can render with nonce', function () { + Livewire::test(MyEmbed::class, ['nonce' => 'abc123']) + ->assertSee('nonce="abc123"', false); +}); + +it('can render with parts', function () { + Livewire::test(MyEmbed::class, ['parts' => ['part1', 'part2']]) + ->assertSee('part="part1 part2"', false); +}); + +it('can render with popOver', function () { + Livewire::test(MyEmbed::class, ['popOver' => true]) + ->assertSee('popover'); +}); + +it('can render with role', function () { + Livewire::test(MyEmbed::class, ['role' => 'main']) + ->assertSee('role="main"', false); +}); + +it('can render with slot', function () { + Livewire::test(MyEmbed::class, ['slotAttribute' => 'main-embed']) + ->assertSee('slot="main-embed"', false); +}); + +it('can render with spellcheck', function () { + Livewire::test(MyEmbed::class, ['spellCheck' => true]) + ->assertSee('spellcheck'); +}); + +it('can render with styles', function () { + Livewire::test(MyEmbed::class, ['styles' => ['color' => 'red', 'font-size' => '16px']]) + ->assertSee('style="color:red;font-size:16px"', false); +}); + +it('can render with tabindex', function () { + Livewire::test(MyEmbed::class, ['tabIndex' => 1]) + ->assertSee('tabindex="1"', false); +}); + +it('can render with title', function () { + Livewire::test(MyEmbed::class, ['title' => 'main-embed']) + ->assertSee('title="main-embed"', false); +}); + +it('can render with translate', function () { + Livewire::test(MyEmbed::class, ['translate' => true]) + ->assertSee('translate'); +}); diff --git a/tests/TestSupport/Components/EmbeddedContent/MyEmbed.php b/tests/TestSupport/Components/EmbeddedContent/MyEmbed.php new file mode 100644 index 00000000..69d8b1fe --- /dev/null +++ b/tests/TestSupport/Components/EmbeddedContent/MyEmbed.php @@ -0,0 +1,7 @@ +