@@ -646,15 +646,15 @@ test('yamlAsJson: failed validation of a multi-document-file', async () => {
646
646
test ( 'successfully skips JSON files that match json_exclude_regex' , async ( ) => {
647
647
process . env . INPUT_JSON_EXCLUDE_REGEX = '.*valid.*\\.json'
648
648
process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid'
649
-
649
+
650
650
expect ( await jsonValidator ( excludeMock ) ) . toStrictEqual ( {
651
651
failed : 0 ,
652
652
passed : 0 ,
653
653
skipped : 1 ,
654
654
success : true ,
655
655
violations : [ ]
656
656
} )
657
-
657
+
658
658
expect ( infoMock ) . toHaveBeenCalledWith (
659
659
expect . stringMatching ( 'skipping due to exclude match:' )
660
660
)
@@ -663,7 +663,7 @@ test('successfully skips JSON files that match json_exclude_regex', async () =>
663
663
test ( 'handles json_exclude_regex with empty string (no exclusion)' , async ( ) => {
664
664
process . env . INPUT_JSON_EXCLUDE_REGEX = ''
665
665
process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid'
666
-
666
+
667
667
expect ( await jsonValidator ( excludeMock ) ) . toStrictEqual ( {
668
668
failed : 0 ,
669
669
passed : 1 ,
@@ -676,11 +676,11 @@ test('handles json_exclude_regex with empty string (no exclusion)', async () =>
676
676
test ( 'processes non-array data correctly (covers data validation branch)' , async ( ) => {
677
677
process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid'
678
678
process . env . INPUT_JSON_SCHEMA = ''
679
-
679
+
680
680
const result = await jsonValidator ( excludeMock )
681
681
expect ( result . success ) . toBe ( true )
682
682
expect ( result . passed ) . toBe ( 1 )
683
-
683
+
684
684
expect ( debugMock ) . toHaveBeenCalledWith (
685
685
expect . stringMatching ( '1 object\\(s\\) found in file:' )
686
686
)
@@ -756,20 +756,22 @@ test('handles use_ajv_formats disabled', async () => {
756
756
violations : [ ]
757
757
} )
758
758
759
- expect ( debugMock ) . toHaveBeenCalledWith ( 'ajv-formats will not be used with the json-validator' )
759
+ expect ( debugMock ) . toHaveBeenCalledWith (
760
+ 'ajv-formats will not be used with the json-validator'
761
+ )
760
762
} )
761
763
762
764
test ( 'handles non-array data processing with single document YAML as JSON' , async ( ) => {
763
765
// This test covers the case where data is not initially an array (line 254)
764
766
process . env . INPUT_YAML_AS_JSON = 'true'
765
- process . env . INPUT_ALLOW_MULTIPLE_DOCUMENTS = 'false' // This makes data not an array initially
767
+ process . env . INPUT_ALLOW_MULTIPLE_DOCUMENTS = 'false' // This makes data not an array initially
766
768
process . env . INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/valid'
767
769
process . env . INPUT_JSON_SCHEMA = ''
768
-
770
+
769
771
const result = await jsonValidator ( excludeMock )
770
772
expect ( result . success ) . toBe ( true )
771
773
expect ( result . passed ) . toBe ( 1 )
772
-
774
+
773
775
// This should trigger the Array.isArray check and the debug message
774
776
expect ( debugMock ) . toHaveBeenCalledWith (
775
777
expect . stringMatching ( '1 object\\(s\\) found in file:' )
@@ -780,29 +782,29 @@ test('edge case: empty json_exclude_regex with complex file structure', async ()
780
782
process . env . INPUT_JSON_EXCLUDE_REGEX = ''
781
783
process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/mixture'
782
784
process . env . INPUT_JSON_SCHEMA = ''
783
-
785
+
784
786
const result = await jsonValidator ( excludeMock )
785
787
expect ( result . passed + result . failed ) . toBeGreaterThan ( 0 )
786
788
} )
787
789
788
790
test ( 'edge case: complex file patterns with multiple extensions' , async ( ) => {
789
- process . env . INPUT_FILES = '__tests__/fixtures/json/valid/*.json\n__tests__/fixtures/yaml_as_json/valid/*.yaml'
791
+ process . env . INPUT_FILES =
792
+ '__tests__/fixtures/json/valid/*.json\n__tests__/fixtures/yaml_as_json/valid/*.yaml'
790
793
process . env . INPUT_YAML_AS_JSON = 'true'
791
794
process . env . INPUT_BASE_DIR = '.'
792
795
process . env . INPUT_JSON_SCHEMA = ''
793
-
796
+
794
797
const result = await jsonValidator ( excludeMock )
795
798
expect ( result . passed ) . toBeGreaterThan ( 0 )
796
-
797
- expect ( debugMock ) . toHaveBeenCalledWith (
798
- expect . stringMatching ( 'using files:' )
799
- )
799
+
800
+ expect ( debugMock ) . toHaveBeenCalledWith ( expect . stringMatching ( 'using files:' ) )
800
801
} )
801
802
802
803
test ( 'edge case: malformed custom regexp formats with complex patterns' , async ( ) => {
803
804
expect . assertions ( 1 )
804
805
try {
805
- process . env . INPUT_AJV_CUSTOM_REGEXP_FORMATS = 'valid_format=^[a-z]+$\ninvalid-format'
806
+ process . env . INPUT_AJV_CUSTOM_REGEXP_FORMATS =
807
+ 'valid_format=^[a-z]+$\ninvalid-format'
806
808
await jsonValidator ( excludeMock )
807
809
} catch ( e ) {
808
810
expect ( e . message ) . toContain ( 'is not in expected format "key=regex"' )
@@ -811,12 +813,13 @@ test('edge case: malformed custom regexp formats with complex patterns', async (
811
813
812
814
test ( 'edge case: schema file skipping logic' , async ( ) => {
813
815
process . env . INPUT_JSON_SCHEMA = '__tests__/fixtures/schemas/schema1.json'
814
- process . env . INPUT_FILES = '__tests__/fixtures/schemas/schema1.json\n__tests__/fixtures/json/valid/json1.json'
816
+ process . env . INPUT_FILES =
817
+ '__tests__/fixtures/schemas/schema1.json\n__tests__/fixtures/json/valid/json1.json'
815
818
process . env . INPUT_BASE_DIR = '.'
816
-
819
+
817
820
const result = await jsonValidator ( excludeMock )
818
821
expect ( result . passed ) . toBe ( 1 ) // Only json1.json should be processed, schema1.json should be skipped
819
-
822
+
820
823
expect ( debugMock ) . toHaveBeenCalledWith (
821
824
expect . stringMatching ( 'skipping json schema file:' )
822
825
)
@@ -827,33 +830,34 @@ test('stress test: large number of custom regex formats', async () => {
827
830
for ( let i = 0 ; i < 10 ; i ++ ) {
828
831
formats . push ( `format${ i } =^test${ i } .*$` )
829
832
}
830
-
833
+
831
834
process . env . INPUT_AJV_CUSTOM_REGEXP_FORMATS = formats . join ( '\n' )
832
835
process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid'
833
836
process . env . INPUT_JSON_SCHEMA = ''
834
-
837
+
835
838
const result = await jsonValidator ( excludeMock )
836
839
expect ( result . success ) . toBe ( true )
837
840
} )
838
841
839
842
test ( 'edge case: duplicate file processing prevention' , async ( ) => {
840
843
// Test that files are not processed multiple times
841
- process . env . INPUT_FILES = '__tests__/fixtures/json/valid/json1.json\n__tests__/fixtures/json/valid/json1.json'
844
+ process . env . INPUT_FILES =
845
+ '__tests__/fixtures/json/valid/json1.json\n__tests__/fixtures/json/valid/json1.json'
842
846
process . env . INPUT_BASE_DIR = '.'
843
847
process . env . INPUT_JSON_SCHEMA = ''
844
-
848
+
845
849
const result = await jsonValidator ( excludeMock )
846
850
expect ( result . passed ) . toBe ( 1 ) // Should only process the file once
847
-
851
+
848
852
expect ( debugMock ) . toHaveBeenCalledWith (
849
853
expect . stringMatching ( 'skipping duplicate file:' )
850
854
)
851
855
} )
852
856
853
857
test ( 'edge case: baseDir with trailing slash normalization' , async ( ) => {
854
- process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid/' // Note trailing slash
858
+ process . env . INPUT_BASE_DIR = '__tests__/fixtures/json/valid/' // Note trailing slash
855
859
process . env . INPUT_JSON_SCHEMA = ''
856
-
860
+
857
861
const result = await jsonValidator ( excludeMock )
858
862
expect ( result . success ) . toBe ( true )
859
863
expect ( result . passed ) . toBe ( 1 )
@@ -864,7 +868,7 @@ test('real world scenario: large schema with draft-2019-09', async () => {
864
868
process . env . INPUT_JSON_SCHEMA = '__tests__/fixtures/schemas/challenge.json'
865
869
process . env . INPUT_BASE_DIR = '__tests__/fixtures/real_world/challenges'
866
870
process . env . INPUT_YAML_AS_JSON = 'true'
867
-
871
+
868
872
const result = await jsonValidator ( excludeMock )
869
873
expect ( result ) . toBeDefined ( )
870
874
expect ( typeof result . success ) . toBe ( 'boolean' )
@@ -875,16 +879,16 @@ test('edge case: potential non-array data with complex yaml parsing', async () =
875
879
const fs = require ( 'fs' )
876
880
const tempFile = '/tmp/complex_yaml.yaml'
877
881
fs . writeFileSync ( tempFile , 'scalar_value' )
878
-
882
+
879
883
process . env . INPUT_YAML_AS_JSON = 'true'
880
884
process . env . INPUT_ALLOW_MULTIPLE_DOCUMENTS = 'false'
881
885
process . env . INPUT_FILES = tempFile
882
886
process . env . INPUT_BASE_DIR = '.'
883
887
process . env . INPUT_JSON_SCHEMA = ''
884
-
888
+
885
889
const result = await jsonValidator ( excludeMock )
886
890
expect ( result . passed ) . toBe ( 1 )
887
-
891
+
888
892
// Cleanup
889
893
fs . unlinkSync ( tempFile )
890
894
} )
@@ -894,16 +898,16 @@ test('edge case: empty document processing', async () => {
894
898
const fs = require ( 'fs' )
895
899
const tempFile = '/tmp/empty.yaml'
896
900
fs . writeFileSync ( tempFile , '' )
897
-
901
+
898
902
process . env . INPUT_YAML_AS_JSON = 'true'
899
903
process . env . INPUT_ALLOW_MULTIPLE_DOCUMENTS = 'false'
900
904
process . env . INPUT_FILES = tempFile
901
905
process . env . INPUT_BASE_DIR = '.'
902
906
process . env . INPUT_JSON_SCHEMA = ''
903
-
907
+
904
908
const result = await jsonValidator ( excludeMock )
905
909
expect ( result . passed + result . failed ) . toBeGreaterThan ( 0 )
906
-
910
+
907
911
// Cleanup
908
912
fs . unlinkSync ( tempFile )
909
913
} )
@@ -913,16 +917,16 @@ test('edge case: malformed JSON in real file', async () => {
913
917
const fs = require ( 'fs' )
914
918
const tempFile = '/tmp/malformed.json'
915
919
fs . writeFileSync ( tempFile , '{"invalid": json, missing quotes}' )
916
-
920
+
917
921
process . env . INPUT_FILES = tempFile
918
922
process . env . INPUT_BASE_DIR = '.'
919
923
process . env . INPUT_JSON_SCHEMA = ''
920
924
process . env . INPUT_YAML_AS_JSON = 'false'
921
-
925
+
922
926
const result = await jsonValidator ( excludeMock )
923
927
expect ( result . failed ) . toBe ( 1 )
924
928
expect ( result . success ) . toBe ( false )
925
-
929
+
926
930
// Cleanup
927
931
fs . unlinkSync ( tempFile )
928
932
} )
0 commit comments