Skip to content

Commit 9c3b7ad

Browse files
committed
update tests
1 parent 8ddeade commit 9c3b7ad

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

__tests__/functions/json-validator.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,25 @@ test('successfully validates json files with a schema when files is defined', as
462462
expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
463463
})
464464

465+
test('successfully validates json files with a schema when files is defined and there are duplicates', async () => {
466+
const files = [
467+
'__tests__/fixtures/json/valid/json1.json',
468+
'__tests__/fixtures/json/valid/json1.json',
469+
'__tests__/fixtures/json/project_dir/data/config/json1.json'
470+
]
471+
process.env.INPUT_FILES = files.join('\n')
472+
473+
expect(await jsonValidator(excludeMock)).toStrictEqual({
474+
failed: 0,
475+
passed: 2,
476+
skipped: 0,
477+
success: true,
478+
violations: []
479+
})
480+
481+
expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
482+
})
483+
465484
test('fails to validate a yaml file with an incorrect schema when yaml_as_json is true', async () => {
466485
process.env.INPUT_YAML_AS_JSON = 'true'
467486
process.env.INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/invalid'

__tests__/functions/yaml-validator.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ test('fails to validate a yaml file without using a schema', async () => {
128128
)
129129
})
130130

131-
test('successfully validates yaml files with a schema when files is defined', async () => {
131+
test('successfully validates yaml files with a schema when files is defined and there are duplicates', async () => {
132+
// this file should only be validated once and not duplicated
132133
const files = [
133134
'__tests__/fixtures/yaml/valid/yaml1.yaml',
134135
'__tests__/fixtures/yaml/valid/yaml1.yaml'
@@ -137,7 +138,7 @@ test('successfully validates yaml files with a schema when files is defined', as
137138

138139
expect(await yamlValidator(excludeMock)).toStrictEqual({
139140
failed: 0,
140-
passed: 2,
141+
passed: 1,
141142
skipped: 0,
142143
success: true,
143144
violations: []

0 commit comments

Comments
 (0)