@@ -22,6 +22,8 @@ beforeEach(() => {
22
22
process . env . INPUT_YAML_AS_JSON = 'false'
23
23
process . env . INPUT_USE_DOT_MATCH = 'true'
24
24
process . env . INPUT_USE_AJV_FORMATS = true
25
+ process . env . INPUT_YAML_EXTENSION = '.yaml'
26
+ process . env . INPUT_YAML_EXTENSION_SHORT = '.yml'
25
27
process . env . INPUT_FILES = ''
26
28
} )
27
29
@@ -200,7 +202,7 @@ test('fails to validate one json file with an incorrect schema and succeeds on t
200
202
} )
201
203
202
204
test ( 'successfully validates a yaml file with a schema when yaml_as_json is true' , async ( ) => {
203
- process . env . INPUT_YAML_AS_JSON = true
205
+ process . env . INPUT_YAML_AS_JSON = ' true'
204
206
process . env . INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/valid'
205
207
206
208
expect ( await jsonValidator ( excludeMock ) ) . toStrictEqual ( {
@@ -212,6 +214,46 @@ test('successfully validates a yaml file with a schema when yaml_as_json is true
212
214
} )
213
215
} )
214
216
217
+ test ( 'processes multiple files when yaml_as_json is true and also a mixture of other json files with yaml are present' , async ( ) => {
218
+ process . env . INPUT_YAML_AS_JSON = 'true'
219
+ process . env . INPUT_JSON_SCHEMA = ''
220
+ process . env . INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/mixture'
221
+
222
+ expect ( await jsonValidator ( excludeMock ) ) . toStrictEqual ( {
223
+ failed : 1 ,
224
+ passed : 3 ,
225
+ skipped : 0 ,
226
+ success : false ,
227
+ violations : [
228
+ {
229
+ file : '__tests__/fixtures/yaml_as_json/mixture/invalid-json.json' ,
230
+ errors : [
231
+ {
232
+ path : null ,
233
+ message : 'Invalid JSON'
234
+ }
235
+ ]
236
+ }
237
+ ]
238
+ } )
239
+
240
+ expect ( debugMock ) . toHaveBeenCalledWith (
241
+ 'using ajv-formats with json-validator'
242
+ )
243
+ expect ( debugMock ) . toHaveBeenCalledWith (
244
+ 'json - using baseDir: __tests__/fixtures/yaml_as_json/mixture'
245
+ )
246
+ expect ( debugMock ) . toHaveBeenCalledWith (
247
+ 'json - using glob: **/*{.json,yaml,yml}'
248
+ )
249
+ expect ( debugMock ) . toHaveBeenCalledWith (
250
+ `attempting to process yaml file: '__tests__/fixtures/yaml_as_json/mixture/yaml1.yaml' as json`
251
+ )
252
+ expect ( debugMock ) . toHaveBeenCalledWith (
253
+ `attempting to process yaml file: '__tests__/fixtures/yaml_as_json/mixture/yaml2.yml' as json`
254
+ )
255
+ } )
256
+
215
257
test ( 'successfully validates json files with a schema when files is defined' , async ( ) => {
216
258
const files = [
217
259
'__tests__/fixtures/json/valid/json1.json' ,
@@ -231,7 +273,7 @@ test('successfully validates json files with a schema when files is defined', as
231
273
} )
232
274
233
275
test ( 'fails to validate a yaml file with an incorrect schema when yaml_as_json is true' , async ( ) => {
234
- process . env . INPUT_YAML_AS_JSON = true
276
+ process . env . INPUT_YAML_AS_JSON = ' true'
235
277
process . env . INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/invalid'
236
278
237
279
expect ( await jsonValidator ( excludeMock ) ) . toStrictEqual ( {
0 commit comments