Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed Jun 9, 2024
1 parent 9fb2d39 commit 0503576
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/_data/manifest-sri.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,23 @@
"src": "demo.ts",
"isEntry": true,
"integrity": "sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8="
},
"demo.sha256.ts": {
"file": "assets/index.deadbeef.js",
"src": "demo.sha256.ts",
"isEntry": true,
"integrity": "sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8="
},
"demo.sha384.ts": {
"file": "assets/index.deadbeef.js",
"src": "demo.sha384.ts",
"isEntry": true,
"integrity": "sha384-fWetO954Htoz6cSa6ZLx231UagP8VTXlwaO1g/JisfA9TLZnHPlgPBUwsqrWHjg0"
},
"demo.sha512.ts": {
"file": "assets/index.deadbeef.js",
"src": "demo.sha512.ts",
"isEntry": true,
"integrity": "sha512-yD2Vb8LCDxC5ingFUTEa50J7EaqoK4xJzwimk2+7PPM9jczPfTDHngkduhYar/pz4dCW7qWIhm0fXFDXm1lL/A=="
}
}
29 changes: 28 additions & 1 deletion tests/unit/ViteManifestSriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function _after()
public function testGetManifest()
{
$actual = $this->vm->getManifest();
$expected = json_decode('{"demo.ts":{"file":"assets/index.deadbeef.js","src":"demo.ts","isEntry":true,"integrity":"sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8="}}', true);
$expected = json_decode('{"demo.ts":{"file":"assets/index.deadbeef.js","src":"demo.ts","isEntry":true,"integrity":"sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8="},"demo.sha256.ts":{"file":"assets/index.deadbeef.js","src":"demo.sha256.ts","isEntry":true,"integrity":"sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8="},"demo.sha384.ts":{"file":"assets/index.deadbeef.js","src":"demo.sha384.ts","isEntry":true,"integrity":"sha384-fWetO954Htoz6cSa6ZLx231UagP8VTXlwaO1g/JisfA9TLZnHPlgPBUwsqrWHjg0"},"demo.sha512.ts":{"file":"assets/index.deadbeef.js","src":"demo.sha512.ts","isEntry":true,"integrity":"sha512-yD2Vb8LCDxC5ingFUTEa50J7EaqoK4xJzwimk2+7PPM9jczPfTDHngkduhYar/pz4dCW7qWIhm0fXFDXm1lL/A=="}}', true);

$this->assertEquals($actual, $expected);
}
Expand All @@ -39,4 +39,31 @@ public function testGetEntryPoint()
$this->assertFileExists($url);
$this->assertEquals($hash, "sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8=");
}

public function testGetEntryPointSHA256()
{
$entrypoint = $this->vm->getEntrypoint('demo.sha256.ts');
["url" => $url, "hash" => $hash] = $entrypoint;

$this->assertFileExists($url);
$this->assertEquals($hash, "sha256-hK5PvH3PaGbMYq5EuedyA6F5uVkfoEwAznLNThffuZ8=");
}

public function testGetEntryPointSHA384()
{
$entrypoint = $this->vm->getEntrypoint('demo.sha384.ts');
["url" => $url, "hash" => $hash] = $entrypoint;

$this->assertFileExists($url);
$this->assertEquals($hash, "sha384-fWetO954Htoz6cSa6ZLx231UagP8VTXlwaO1g/JisfA9TLZnHPlgPBUwsqrWHjg0");
}

public function testGetEntryPointSHA512()
{
$entrypoint = $this->vm->getEntrypoint('demo.sha512.ts');
["url" => $url, "hash" => $hash] = $entrypoint;

$this->assertFileExists($url);
$this->assertEquals($hash, "sha512-yD2Vb8LCDxC5ingFUTEa50J7EaqoK4xJzwimk2+7PPM9jczPfTDHngkduhYar/pz4dCW7qWIhm0fXFDXm1lL/A==");
}
}

0 comments on commit 0503576

Please sign in to comment.