@@ -7,27 +7,16 @@ describe('laravel-vite-plugin', () => {
77 vi . clearAllMocks ( )
88 } )
99
10- it ( 'provides sensible default values' , ( ) => {
11- const plugin = laravel ( )
12- expect ( plugin . name ) . toBe ( 'laravel' )
13-
14- const buildConfig = plugin . config ( { } , { command : 'build' , mode : 'production' } )
15- expect ( buildConfig . base ) . toBe ( '/build/' )
16- expect ( buildConfig . build . manifest ) . toBe ( true )
17- expect ( buildConfig . build . outDir ) . toBe ( 'public/build' )
18- expect ( buildConfig . build . rollupOptions . input ) . toEqual ( [ 'resources/css/app.css' , 'resources/js/app.js' ] )
19-
20- const serveConfig = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
21- expect ( serveConfig . base ) . toBe ( '' )
22- expect ( buildConfig . server . host ) . toBeUndefined ( )
23- expect ( buildConfig . server . port ) . toBeUndefined ( )
24- expect ( buildConfig . server . strictPort ) . toBeUndefined ( )
10+ it ( 'handles missing configuration' , ( ) => {
11+ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
12+ /* @ts -ignore */
13+ expect ( ( ) => laravel ( ) )
14+ . toThrowError ( 'Missing configuration' ) ;
2515
26- const ssrConfig = plugin . config ( { build : { ssr : true } } , { command : 'build' , mode : 'production' } )
27- expect ( ssrConfig . base ) . toBe ( '/build/' )
28- expect ( ssrConfig . build . manifest ) . toBe ( false )
29- expect ( ssrConfig . build . outDir ) . toBe ( 'storage/ssr' )
30- expect ( ssrConfig . build . rollupOptions . input ) . toBe ( 'resources/js/ssr.js' )
16+ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
17+ /* @ts -ignore */
18+ expect ( ( ) => laravel ( { } ) )
19+ . toThrowError ( 'Missing configuration for key: input' ) ;
3120 } )
3221
3322 it ( 'accepts a single input' , ( ) => {
@@ -108,17 +97,18 @@ describe('laravel-vite-plugin', () => {
10897 } )
10998
11099 it ( 'prevents setting an empty publicDirectory' , ( ) => {
111- expect ( ( ) => laravel ( { publicDirectory : '' } ) )
100+ expect ( ( ) => laravel ( { input : 'resources/js/app.js' , publicDirectory : '' } ) )
112101 . toThrowError ( 'publicDirectory must be a subdirectory' ) ;
113102 } )
114103
115104 it ( 'prevents setting an empty buildDirectory' , ( ) => {
116- expect ( ( ) => laravel ( { buildDirectory : '' } ) )
105+ expect ( ( ) => laravel ( { input : 'resources/js/app.js' , buildDirectory : '' } ) )
117106 . toThrowError ( 'buildDirectory must be a subdirectory' ) ;
118107 } )
119108
120109 it ( 'handles surrounding slashes on directories' , ( ) => {
121110 const plugin = laravel ( {
111+ input : 'resources/js/app.js' ,
122112 publicDirectory : '/public/test/' ,
123113 buildDirectory : '/build/test/' ,
124114 ssrOutputDirectory : '/ssr-output/test/' ,
@@ -197,7 +187,7 @@ describe('laravel-vite-plugin', () => {
197187
198188 it ( 'configures the Vite server when inside a Sail container' , ( ) => {
199189 process . env . LARAVEL_SAIL = '1'
200- const plugin = laravel ( )
190+ const plugin = laravel ( 'resources/js/app.js' )
201191
202192 const config = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
203193 expect ( config . server . host ) . toBe ( '0.0.0.0' )
@@ -210,7 +200,7 @@ describe('laravel-vite-plugin', () => {
210200 it ( 'allows the Vite port to be configured when inside a Sail container' , ( ) => {
211201 process . env . LARAVEL_SAIL = '1'
212202 process . env . VITE_PORT = '1234'
213- const plugin = laravel ( )
203+ const plugin = laravel ( 'resources/js/app.js' )
214204
215205 const config = plugin . config ( { } , { command : 'serve' , mode : 'development' } )
216206 expect ( config . server . host ) . toBe ( '0.0.0.0' )
0 commit comments