mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-22 21:54:15 +02:00
Added ViteTest
This commit is contained in:
43
tests/ViewFunctions/ViteTest.php
Normal file
43
tests/ViewFunctions/ViteTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\ViewFunctions;
|
||||
|
||||
use App\ViewFunctions\Vite;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
#[CoversClass(Vite::class)]
|
||||
class ViteTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function it_can_get_tags_for_a_list_of_assets_when_in_dev_mode(): void
|
||||
{
|
||||
$this->container->set('asset_path', $this->filePath('.'));
|
||||
|
||||
$vite = $this->container->get(Vite::class);
|
||||
|
||||
$tags = $vite(['app/resources/js/app.js', 'app/resources/css/app.css']);
|
||||
|
||||
$this->assertSame(<<<HTML
|
||||
<script type="module" src="http://localhost:5173/@vite/client"></script>
|
||||
<script type="module" src="http://localhost:5173/app/resources/js/app.js"></script>
|
||||
<link rel="stylesheet" href="http://localhost:5173/app/resources/css/app.css">
|
||||
HTML, $tags);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_can_get_tags_for_a_list_of_assets_when_in_build_mode(): void
|
||||
{
|
||||
$this->container->set('assets_path', $this->filePath('app/assets'));
|
||||
|
||||
$vite = $this->container->get(Vite::class);
|
||||
|
||||
$tags = $vite(['app/resources/js/app.js', 'app/resources/css/app.css']);
|
||||
|
||||
$this->assertSame(<<<HTML
|
||||
<script type="module" src="app/assets/app-DwN9UvfZ.js"></script>
|
||||
<link rel="stylesheet" href="app/assets/app-DcdLJcW2.css">
|
||||
HTML, $tags);
|
||||
}
|
||||
}
|
13
tests/_files/app/assets/manifest.json
Normal file
13
tests/_files/app/assets/manifest.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"app/resources/css/app.css": {
|
||||
"file": "app/assets/app-DcdLJcW2.css",
|
||||
"src": "app/resources/css/app.css",
|
||||
"isEntry": true
|
||||
},
|
||||
"app/resources/js/app.js": {
|
||||
"file": "app/assets/app-DwN9UvfZ.js",
|
||||
"name": "app",
|
||||
"src": "app/resources/js/app.js",
|
||||
"isEntry": true
|
||||
}
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"/app.css": "/app.css?id=417c7a9bc03852aafb27",
|
||||
"/app.js": "/app.js?id=6753a7269276c7b52692"
|
||||
}
|
Reference in New Issue
Block a user