11import { describe , expect , it } from 'vitest' ;
22import {
3- artifactGenerationCommand ,
3+ artifactGenerationCommandSchema ,
44 pluginArtifactOptionsSchema ,
55} from './configuration.js' ;
66
7- describe ( 'artifactGenerationCommand ' , ( ) => {
7+ describe ( 'artifactGenerationCommandSchema ' , ( ) => {
88 it ( 'should validate a command with required fields' , ( ) => {
99 const data = { command : 'npx' } ;
10- expect ( artifactGenerationCommand . safeParse ( data ) ) . toStrictEqual ( {
10+ expect ( artifactGenerationCommandSchema . safeParse ( data ) ) . toStrictEqual ( {
1111 success : true ,
1212 data : { command : 'npx' } ,
1313 } ) ;
1414 } ) ;
1515
1616 it ( 'should validate a command with args' , ( ) => {
1717 const data = { command : 'npx' , args : [ 'eslint' , 'src/' ] } ;
18- expect ( artifactGenerationCommand . safeParse ( data ) ) . toStrictEqual ( {
18+ expect ( artifactGenerationCommandSchema . safeParse ( data ) ) . toStrictEqual ( {
1919 success : true ,
2020 data : { command : 'npx' , args : [ 'eslint' , 'src/' ] } ,
2121 } ) ;
2222 } ) ;
2323
2424 it ( 'should fail if command is missing' , ( ) => {
2525 const data = { args : [ 'eslint' , 'src/' ] } ;
26- expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
26+ expect ( artifactGenerationCommandSchema . safeParse ( data ) . success ) . toBe ( false ) ;
2727 } ) ;
2828
2929 it ( 'should fail if command is empty' , ( ) => {
3030 const data = { command : '' } ;
31- expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
31+ expect ( artifactGenerationCommandSchema . safeParse ( data ) . success ) . toBe ( false ) ;
3232 } ) ;
3333
3434 it ( 'should fail if args is not an array of strings' , ( ) => {
3535 const data = { command : 'npx' , args : [ 123 , true ] } ;
36- expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
36+ expect ( artifactGenerationCommandSchema . safeParse ( data ) . success ) . toBe ( false ) ;
3737 } ) ;
3838} ) ;
3939
@@ -63,22 +63,22 @@ describe('pluginArtifactOptionsSchema', () => {
6363 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
6464 } ) ;
6565
66- it ( 'should validate with generateArtifacts and artifactsPaths' , ( ) => {
66+ it ( 'should validate with generateArtifactsCommand and artifactsPaths' , ( ) => {
6767 const data = {
68- generateArtifacts : { command : 'npm' , args : [ 'run' , 'build' ] } ,
68+ generateArtifactsCommand : { command : 'npm' , args : [ 'run' , 'build' ] } ,
6969 artifactsPaths : [ 'dist/report.json' ] ,
7070 } ;
7171 expect ( pluginArtifactOptionsSchema . safeParse ( data ) ) . toStrictEqual ( {
7272 success : true ,
7373 data : {
74- generateArtifacts : { command : 'npm' , args : [ 'run' , 'build' ] } ,
74+ generateArtifactsCommand : { command : 'npm' , args : [ 'run' , 'build' ] } ,
7575 artifactsPaths : [ 'dist/report.json' ] ,
7676 } ,
7777 } ) ;
7878 } ) ;
7979
8080 it ( 'should fail if artifactsPaths is missing' , ( ) => {
81- const data = { generateArtifacts : { command : 'npm' } } ;
81+ const data = { generateArtifactsCommand : { command : 'npm' } } ;
8282 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
8383 } ) ;
8484
@@ -87,39 +87,39 @@ describe('pluginArtifactOptionsSchema', () => {
8787 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
8888 } ) ;
8989
90- it ( 'should fail if generateArtifacts is invalid' , ( ) => {
90+ it ( 'should fail if generateArtifactsCommand is invalid' , ( ) => {
9191 const data = {
92- generateArtifacts : { command : '' } ,
92+ generateArtifactsCommand : { command : '' } ,
9393 artifactsPaths : 'dist/report.json' ,
9494 } ;
9595 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
9696 } ) ;
9797
98- it ( 'should validate with generateArtifacts as a string' , ( ) => {
98+ it ( 'should validate with generateArtifactsCommand as a string' , ( ) => {
9999 const data = {
100- generateArtifacts : 'yarn test --coverage' ,
100+ generateArtifactsCommand : 'yarn test --coverage' ,
101101 artifactsPaths : 'coverage/lcov.info' ,
102102 } ;
103103 expect ( pluginArtifactOptionsSchema . safeParse ( data ) ) . toStrictEqual ( {
104104 success : true ,
105105 data : {
106- generateArtifacts : 'yarn test --coverage' ,
106+ generateArtifactsCommand : 'yarn test --coverage' ,
107107 artifactsPaths : 'coverage/lcov.info' ,
108108 } ,
109109 } ) ;
110110 } ) ;
111111
112- it ( 'should fail if generateArtifacts is an empty string' , ( ) => {
112+ it ( 'should fail if generateArtifactsCommand is an empty string' , ( ) => {
113113 const data = {
114- generateArtifacts : '' ,
114+ generateArtifactsCommand : '' ,
115115 artifactsPaths : 'coverage/lcov.info' ,
116116 } ;
117117 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
118118 } ) ;
119119
120- it ( 'should fail if generateArtifacts is a number' , ( ) => {
120+ it ( 'should fail if generateArtifactsCommand is a number' , ( ) => {
121121 const data = {
122- generateArtifacts : 123 ,
122+ generateArtifactsCommand : 123 ,
123123 artifactsPaths : 'coverage/lcov.info' ,
124124 } ;
125125 expect ( pluginArtifactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
0 commit comments