@@ -7,89 +7,93 @@ import {
77describe ( 'artifactGenerationCommand' , ( ) => {
88 it ( 'should validate a command with required fields' , ( ) => {
99 const data = { command : 'npx' } ;
10- const result = artifactGenerationCommand . safeParse ( data ) ;
11- expect ( result . success ) . toBe ( true ) ;
12- if ( result . success ) {
13- expect ( result . data . command ) . toBe ( 'npx' ) ;
14- expect ( result . data . args ) . toBeUndefined ( ) ;
15- }
10+ expect ( artifactGenerationCommand . safeParse ( data ) ) . toStrictEqual ( {
11+ success : true ,
12+ data : { command : 'npx' } ,
13+ } ) ;
1614 } ) ;
1715
1816 it ( 'should validate a command with args' , ( ) => {
1917 const data = { command : 'npx' , args : [ 'eslint' , 'src/' ] } ;
20- const result = artifactGenerationCommand . safeParse ( data ) ;
21- expect ( result . success ) . toBe ( true ) ;
22- if ( result . success ) {
23- expect ( result . data . command ) . toBe ( 'npx' ) ;
24- expect ( result . data . args ) . toEqual ( [ 'eslint' , 'src/' ] ) ;
25- }
18+ expect ( artifactGenerationCommand . safeParse ( data ) ) . toStrictEqual ( {
19+ success : true ,
20+ data : { command : 'npx' , args : [ 'eslint' , 'src/' ] } ,
21+ } ) ;
2622 } ) ;
2723
2824 it ( 'should fail if command is missing' , ( ) => {
2925 const data = { args : [ 'eslint' , 'src/' ] } ;
30- const result = artifactGenerationCommand . safeParse ( data ) ;
31- expect ( result . success ) . toBe ( false ) ;
26+ expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
3227 } ) ;
3328
3429 it ( 'should fail if command is empty' , ( ) => {
3530 const data = { command : '' } ;
36- const result = artifactGenerationCommand . safeParse ( data ) ;
37- expect ( result . success ) . toBe ( false ) ;
31+ expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
3832 } ) ;
3933
4034 it ( 'should fail if args is not an array of strings' , ( ) => {
4135 const data = { command : 'npx' , args : [ 123 , true ] } ;
42- const result = artifactGenerationCommand . safeParse ( data ) ;
43- expect ( result . success ) . toBe ( false ) ;
36+ expect ( artifactGenerationCommand . safeParse ( data ) . success ) . toBe ( false ) ;
4437 } ) ;
4538} ) ;
4639
4740describe ( 'pluginArtefactOptionsSchema' , ( ) => {
4841 it ( 'should validate with only artefactsPaths as string' , ( ) => {
4942 const data = { artefactsPaths : 'dist/report.json' } ;
50- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
51- expect ( success ) . toBe ( true ) ;
43+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) ) . toStrictEqual ( {
44+ success : true ,
45+ data : {
46+ artefactsPaths : 'dist/report.json' ,
47+ generateArtefacts : undefined ,
48+ } ,
49+ } ) ;
5250 } ) ;
5351
5452 it ( 'should validate with artefactsPaths as array of strings' , ( ) => {
5553 const data = { artefactsPaths : [ 'dist/report.json' , 'dist/summary.json' ] } ;
56- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
57- expect ( success ) . toBe ( true ) ;
54+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) ) . toStrictEqual ( {
55+ success : true ,
56+ data : {
57+ artefactsPaths : [ 'dist/report.json' , 'dist/summary.json' ] ,
58+ generateArtefacts : undefined ,
59+ } ,
60+ } ) ;
5861 } ) ;
5962
6063 it ( 'should fail if artefactsPaths is an empty array' , ( ) => {
6164 const data = { artefactsPaths : [ ] } ;
62- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
63- expect ( success ) . toBe ( false ) ;
65+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
6466 } ) ;
6567
6668 it ( 'should validate with generateArtefacts and artefactsPaths' , ( ) => {
6769 const data = {
6870 generateArtefacts : { command : 'npm' , args : [ 'run' , 'build' ] } ,
6971 artefactsPaths : [ 'dist/report.json' ] ,
7072 } ;
71- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
72- expect ( success ) . toBe ( true ) ;
73+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) ) . toStrictEqual ( {
74+ success : true ,
75+ data : {
76+ generateArtefacts : { command : 'npm' , args : [ 'run' , 'build' ] } ,
77+ artefactsPaths : [ 'dist/report.json' ] ,
78+ } ,
79+ } ) ;
7380 } ) ;
7481
7582 it ( 'should fail if artefactsPaths is missing' , ( ) => {
7683 const data = { generateArtefacts : { command : 'npm' } } ;
77- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
78- expect ( success ) . toBe ( false ) ;
84+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
7985 } ) ;
8086
8187 it ( 'should fail if artefactsPaths is not string or array of strings' , ( ) => {
8288 const data = { artefactsPaths : 123 } ;
83- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
84- expect ( success ) . toBe ( false ) ;
89+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
8590 } ) ;
8691
8792 it ( 'should fail if generateArtefacts is invalid' , ( ) => {
8893 const data = {
8994 generateArtefacts : { command : '' } ,
9095 artefactsPaths : 'dist/report.json' ,
9196 } ;
92- const { success } = pluginArtefactOptionsSchema . safeParse ( data ) ;
93- expect ( success ) . toBe ( false ) ;
97+ expect ( pluginArtefactOptionsSchema . safeParse ( data ) . success ) . toBe ( false ) ;
9498 } ) ;
9599} ) ;
0 commit comments