Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 24, 2024
1 parent 8ddeade commit 9c3b7ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions __tests__/functions/json-validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,25 @@ test('successfully validates json files with a schema when files is defined', as
expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
})

test('successfully validates json files with a schema when files is defined and there are duplicates', async () => {
const files = [
'__tests__/fixtures/json/valid/json1.json',
'__tests__/fixtures/json/valid/json1.json',
'__tests__/fixtures/json/project_dir/data/config/json1.json'
]
process.env.INPUT_FILES = files.join('\n')

expect(await jsonValidator(excludeMock)).toStrictEqual({
failed: 0,
passed: 2,
skipped: 0,
success: true,
violations: []
})

expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
})

test('fails to validate a yaml file with an incorrect schema when yaml_as_json is true', async () => {
process.env.INPUT_YAML_AS_JSON = 'true'
process.env.INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/invalid'
Expand Down
5 changes: 3 additions & 2 deletions __tests__/functions/yaml-validator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ test('fails to validate a yaml file without using a schema', async () => {
)
})

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

expect(await yamlValidator(excludeMock)).toStrictEqual({
failed: 0,
passed: 2,
passed: 1,
skipped: 0,
success: true,
violations: []
Expand Down

0 comments on commit 9c3b7ad

Please sign in to comment.