@@ -304,3 +304,63 @@ test.serial("ui5 --output-style", async (t) => {
304304 message : / ^ ( (? ! A r g u m e n t : o u t p u t - s t y l e , G i v e n : " D e f a u l t ) .) * $ / s
305305 } , "Does not throw an exception because of the --output-style input" ) ;
306306} ) ;
307+
308+ test . serial ( "ui5 build --cache" , async ( t ) => {
309+ // "--cache" uses a coerce to normalize the input letter case and to map "read-only" / "readonly"
310+ // variants to "ReadOnly". Since the coerce is hard to test in isolation, we check the result by
311+ // observing yargs' choice validation: invalid input is reported with the normalized form, while
312+ // valid (lower-case) input passes the choice validation and only fails later because there is no
313+ // project to build.
314+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "nonExistent" ] ) , {
315+ message : / A r g u m e n t : c a c h e , G i v e n : " N o n e x i s t e n t " , C h o i c e s : " D e f a u l t " , " F o r c e " , " R e a d O n l y " , " O f f " / s
316+ } , "Coercion correctly capitalizes the first letter and makes the rest lowercase" ) ;
317+
318+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "default" ] ) , {
319+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " D e f a u l t ) .) * $ / s
320+ } , "Does not throw an exception because of the --cache input ('default' coerced to 'Default')" ) ;
321+
322+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "FORCE" ] ) , {
323+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " F o r c e ) .) * $ / s
324+ } , "Does not throw an exception because of the --cache input ('FORCE' coerced to 'Force')" ) ;
325+
326+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "OfF" ] ) , {
327+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " O f f ) .) * $ / s
328+ } , "Does not throw an exception because of the --cache input ('OfF' coerced to 'Off')" ) ;
329+
330+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "readonly" ] ) , {
331+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
332+ } , "Does not throw an exception because of the --cache input ('readonly' coerced to 'ReadOnly')" ) ;
333+
334+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "READONLY" ] ) , {
335+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
336+ } , "Does not throw an exception because of the --cache input ('READONLY' coerced to 'ReadOnly')" ) ;
337+
338+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "read-only" ] ) , {
339+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
340+ } , "Does not throw an exception because of the --cache input ('read-only' coerced to 'ReadOnly')" ) ;
341+
342+ await t . throwsAsync ( ui5 ( [ "build" , "--cache" , "Read-Only" ] ) , {
343+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
344+ } , "Does not throw an exception because of the --cache input ('Read-Only' coerced to 'ReadOnly')" ) ;
345+ } ) ;
346+
347+ test . serial ( "ui5 serve --cache" , async ( t ) => {
348+ // Same pattern as the "ui5 build --cache" test above. "ui5 serve" also fails outside of a
349+ // UI5 project, so we can observe whether the failure is caused by the choice validation
350+ // of the --cache option.
351+ await t . throwsAsync ( ui5 ( [ "serve" , "--cache" , "nonExistent" ] ) , {
352+ message : / A r g u m e n t : c a c h e , G i v e n : " N o n e x i s t e n t " , C h o i c e s : " D e f a u l t " , " F o r c e " , " R e a d O n l y " , " O f f " / s
353+ } , "Coercion correctly capitalizes the first letter and makes the rest lowercase" ) ;
354+
355+ await t . throwsAsync ( ui5 ( [ "serve" , "--cache" , "force" ] ) , {
356+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " F o r c e ) .) * $ / s
357+ } , "Does not throw an exception because of the --cache input ('force' coerced to 'Force')" ) ;
358+
359+ await t . throwsAsync ( ui5 ( [ "serve" , "--cache" , "readonly" ] ) , {
360+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
361+ } , "Does not throw an exception because of the --cache input ('readonly' coerced to 'ReadOnly')" ) ;
362+
363+ await t . throwsAsync ( ui5 ( [ "serve" , "--cache" , "read-only" ] ) , {
364+ message : / ^ ( (? ! A r g u m e n t : c a c h e , G i v e n : " R e a d O n l y ) .) * $ / s
365+ } , "Does not throw an exception because of the --cache input ('read-only' coerced to 'ReadOnly')" ) ;
366+ } ) ;
0 commit comments