Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Aug 26, 2024
1 parent a9442dd commit 9595d92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 13 additions & 1 deletion tests/pest/Feature/ComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit 9595d92

Please sign in to comment.