Skip to content

Commit

Permalink
Tweak test names
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Feb 14, 2024
1 parent 7c8b118 commit 220d64f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
14 changes: 7 additions & 7 deletions tests/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ _Tests the creation of components._

_Tests the component controller._

![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Render.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Render null.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Render array.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Render model.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Controller action success.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Controller action error.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Render without params.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Rendering an empty template.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Rendering component without params throws an exception.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Running an action that returns `null`.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Running an action that returns an array.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Running an action that returns a model.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Running a save action that results in a success.
![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Running a save action that results in an error.

### [Parsing](pest/Feature/ParsingTest.php)

Expand Down
23 changes: 11 additions & 12 deletions tests/pest/Feature/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Craft::$app->getView()->setTemplatesPath(Craft::getAlias('@putyourlightson/sprig/test/templates'));
});

test('Render', function() {
test('Rendering an empty template', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_empty"}'),
]);
Expand All @@ -29,7 +29,12 @@
->toBe('');
});

test('Render null', function() {
test('Rendering component without params throws an exception', function() {
Craft::$app->getRequest()->setQueryParams([]);
Sprig::$core->runAction('components/render');
})->throws(BadRequestHttpException::class);

test('Running an action that returns `null`', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_action"}'),
'sprig:action' => Craft::$app->security->hashData('sprig-core/test/get-null'),
Expand All @@ -52,7 +57,7 @@
);
});

test('Render array', function() {
test('Running an action that returns an array', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_action"}'),
'sprig:action' => Craft::$app->security->hashData('sprig-core/test/get-array'),
Expand All @@ -75,7 +80,7 @@
);
});

test('Render model', function() {
test('Running an action that returns a model', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_action"}'),
'sprig:action' => Craft::$app->security->hashData('sprig-core/test/get-model'),
Expand All @@ -98,7 +103,7 @@
);
});

test('Controller action success', function() {
test('Running a save action that results in a success', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_action"}'),
'sprig:action' => Craft::$app->security->hashData('sprig-core/test/save-success'),
Expand All @@ -123,7 +128,7 @@
);
});

test('Controller action error', function() {
test('Running a save action that results in an error', function() {
Craft::$app->getRequest()->setQueryParams([
'sprig:config' => Craft::$app->security->hashData('{"template":"_action"}'),
'sprig:action' => Craft::$app->security->hashData('sprig-core/test/save-error'),
Expand All @@ -147,9 +152,3 @@
'model',
);
});

test('Render without params', function() {
Craft::$app->getRequest()->setQueryParams([]);
Sprig::$core->runAction('components/render');
})->throws(BadRequestHttpException::class);

0 comments on commit 220d64f

Please sign in to comment.