Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Aug 18, 2024
1 parent 25ba4a2 commit 2fb3468
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/Feature/InjectsAssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,44 @@

use Leuverink\AssetInjector\Contracts\AssetInjector;

it('injects assets into head tag', function () {
it('injects assets into response', function () {
Route::get('test-inject-in-response', fn () => '<html><head></head></html>');

$this->get('test-inject-in-response')
->assertOk()
->assertSee('<!--[TEST_PACKAGE]-->', false);
});

it('injects assets into head tag', function () {
Route::get('test-inject-in-response', fn () => '<html><head></head></html>');

$expected = <<< 'HTML'
<html><head>
<!--[TEST_PACKAGE]-->
TEST_PACKAGE_ASSETS_INJECTED
<!--[ENDTEST_PACKAGE]-->
</head></html>
HTML;

$this->get('test-inject-in-response')
->assertOk()
->assertSee($expected, false);
});

it('injects assets into html body when no head tag is present', function () {
Route::get('test-inject-in-response', fn () => '<html></html>');

$expected = <<< 'HTML'
<html>
<!--[TEST_PACKAGE]-->
TEST_PACKAGE_ASSETS_INJECTED
<!--[ENDTEST_PACKAGE]-->
</html>
HTML;

$this->get('test-inject-in-response')
->assertOk()
->assertSee('<!--[TEST_PACKAGE]-->', false);
->assertSee($expected, false);
});

it('doesnt inject assets into responses without a closing html tag', function () {
Expand Down

0 comments on commit 2fb3468

Please sign in to comment.