22
33use mindplay \vite \Manifest ;
44
5- use function mindplay \testies \{ configure , eq , run , test };
5+ use function mindplay \testies \{ configure , eq , expect , run , test };
66
77require __DIR__ . '/../vendor/autoload.php ' ;
88
@@ -99,7 +99,7 @@ function () {
9999
100100 $ vite ->preloadImages ();
101101
102- $ tags = $ vite ->createTags ("main.js " , "views/foo .js " );
102+ $ tags = $ vite ->createTags ("main.js " , "consent-banner .js " );
103103
104104 eq (
105105 explode ("\n" , $ tags ->preload ),
@@ -110,7 +110,7 @@ function () {
110110 // Preload module shared by both entry points, no duplicates:
111111 '<link rel="modulepreload" href="/dist/assets/shared.83069a53.js" /> ' ,
112112 // Preload `views/foo.js` entry point script:
113- '<link rel="modulepreload" href="/dist/assets/foo.869aea0d .js" /> ' ,
113+ '<link rel="modulepreload" href="/dist/assets/consent-banner.0e3b3b7b .js" /> ' ,
114114 ],
115115 );
116116
@@ -121,6 +121,8 @@ function () {
121121 '<link rel="stylesheet" href="/dist/assets/main.b82dbe22.css" /> ' ,
122122 // CSS shared by both entry points, no duplicates:
123123 '<link rel="stylesheet" href="/dist/assets/shared.a834bfc3.css" /> ' ,
124+ // CSS imported by the consent-banner entry point script:
125+ '<link rel="stylesheet" href="/dist/assets/consent-banner.8ba40300.css" /> ' ,
124126 ]
125127 );
126128
@@ -129,11 +131,44 @@ function () {
129131 [
130132 // Main entry point script:
131133 '<script type="module" src="/dist/assets/main.4889e940.js"></script> ' ,
134+ // Consent-banner entry point script:
135+ '<script type="module" src="/dist/assets/consent-banner.0e3b3b7b.js"></script> ' ,
132136 ]
133137 );
134138 }
135139);
136140
141+ test (
142+ "should throw an exception when an entry is not found, or has the wrong type " ,
143+ function () {
144+ $ vite = new Manifest (
145+ dev: false ,
146+ manifest_path: __DIR__ .'/fixtures/manifest.json ' ,
147+ base_path: '/dist/ '
148+ );
149+
150+ $ vite ->preloadImages ();
151+
152+ expect (
153+ RuntimeException::class,
154+ "`does-not-exist.js` does... not exist :-) " ,
155+ function () use ($ vite ) {
156+ $ tags = $ vite ->createTags ("main.js " , "does-not-exist.js " );
157+ },
158+ "/Entry not found in manifest \\: does-not-exist \\.js/ "
159+ );
160+
161+ expect (
162+ RuntimeException::class,
163+ "`does-not-exist.js` does... not exist :-) " ,
164+ function () use ($ vite ) {
165+ $ tags = $ vite ->createTags ("views/foo.js " );
166+ },
167+ "/Chunk is not an entry point \\: views \\/foo \\.js/ "
168+ );
169+ }
170+ );
171+
137172test (
138173 "can create asset URLs " ,
139174 function () {
0 commit comments