diff --git a/tests/TESTS.md b/tests/TESTS.md index 262bb14..8ccebca 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -11,6 +11,7 @@ This document outlines the test specification for the Sprig Core module. _Tests the creation of components._ ![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Creating a component with variables and options. +![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Creating a component with an ID passed in as a string. ![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Creating an empty component. ![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Creating an invalid component throws an exception. ![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Creating an object from a component. diff --git a/tests/pest/Feature/ComponentsTest.php b/tests/pest/Feature/ComponentsTest.php index 0cd37eb..98f258f 100644 --- a/tests/pest/Feature/ComponentsTest.php +++ b/tests/pest/Feature/ComponentsTest.php @@ -7,7 +7,6 @@ use craft\elements\Entry; use putyourlightson\sprig\errors\FriendlyInvalidVariableException; use putyourlightson\sprig\Sprig; -use putyourlightson\sprig\test\components\TestComponent; use Twig\Markup; use yii\base\Model; use yii\web\BadRequestHttpException; @@ -43,6 +42,19 @@ ); }); +test('Creating a component with an ID passed in as a string', function() { + $markup = Sprig::$core->components->create( + '_component', + [], + 'abc' + ); + + expect((string)$markup) + ->toContain( + 'id="abc"', + ); +}); + test('Creating an empty component', function() { $markup = Sprig::$core->components->create('_empty');