Added ViteTest

This commit is contained in:
Chris Kankiewicz
2025-03-18 13:59:03 -07:00
parent b0877a3bf7
commit 6f305eebb8
3 changed files with 56 additions and 4 deletions

View 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);
}
}

View 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
}
}

View File

@@ -1,4 +0,0 @@
{
"/app.css": "/app.css?id=417c7a9bc03852aafb27",
"/app.js": "/app.js?id=6753a7269276c7b52692"
}