1+ import { jsonValidator } from '../src/functions/json-validator'
2+ import { yamlValidator } from '../src/functions/yaml-validator'
3+ import { Exclude } from '../src/functions/exclude'
4+
5+ const originalEnv = process . env
6+
7+ beforeEach ( ( ) => {
8+ jest . clearAllMocks ( )
9+ process . env = { ...originalEnv }
10+
11+ // Set default environment variables
12+ process . env . INPUT_BASE_DIR = '.'
13+ process . env . INPUT_JSON_EXTENSION = '.json'
14+ process . env . INPUT_JSON_EXCLUDE_REGEX = ''
15+ process . env . INPUT_JSON_SCHEMA = ''
16+ process . env . INPUT_YAML_EXTENSION = '.yaml'
17+ process . env . INPUT_YAML_EXTENSION_SHORT = '.yml'
18+ process . env . INPUT_YAML_EXCLUDE_REGEX = ''
19+ process . env . INPUT_YAML_SCHEMA = ''
20+ process . env . INPUT_YAML_AS_JSON = 'false'
21+ process . env . INPUT_USE_DOT_MATCH = 'true'
22+ process . env . INPUT_ALLOW_MULTIPLE_DOCUMENTS = 'false'
23+ process . env . INPUT_USE_GITIGNORE = 'false'
24+ process . env . INPUT_EXCLUDE_FILE = ''
25+ process . env . INPUT_EXCLUDE_FILE_REQUIRED = 'false'
26+ process . env . INPUT_GIT_IGNORE_PATH = '.gitignore'
27+ process . env . INPUT_AJV_STRICT_MODE = 'true'
28+ process . env . INPUT_JSON_SCHEMA_VERSION = 'draft-07'
29+ process . env . INPUT_USE_AJV_FORMATS = 'false'
30+ } )
31+
32+ afterEach ( ( ) => {
33+ process . env = originalEnv
34+ } )
35+
36+ describe ( 'file duplication and extension issue reproduction' , ( ) => {
37+ test ( 'reproduces the issue from bug report #70' , async ( ) => {
38+ // Setup the scenario from the issue using test fixtures
39+ process . env . INPUT_FILES = '__tests__/fixtures/json/valid/json1.json\n__tests__/fixtures/yaml/valid/yaml1.yaml'
40+
41+ const excludeMock = new Exclude ( )
42+
43+ // Run both validators like in main.js
44+ const jsonResults = await jsonValidator ( excludeMock )
45+ const yamlResults = await yamlValidator ( excludeMock )
46+
47+ // Expectations based on the correct behavior
48+ // JSON validator should process only the .json file
49+ expect ( jsonResults . passed ) . toBe ( 1 )
50+ expect ( jsonResults . failed ) . toBe ( 0 )
51+ expect ( jsonResults . skipped ) . toBe ( 0 )
52+
53+ // YAML validator should process only the .yaml file
54+ expect ( yamlResults . passed ) . toBe ( 1 )
55+ expect ( yamlResults . failed ) . toBe ( 0 )
56+ expect ( yamlResults . skipped ) . toBe ( 0 )
57+
58+ console . log ( 'JSON Results:' , jsonResults )
59+ console . log ( 'YAML Results:' , yamlResults )
60+ } )
61+ } )
0 commit comments