import { readJson} from './json-helper.js';

describe('Json helper test suite', () => {
    beforeEach(() => {
        jest.clearAllMocks();
    });

    describe('readJson', () => {
        const mockJsonObject = { key: 'value' };
        const mockJsonString = '{"key":"value"}';
        const mockFileName = 'test.json'

        it('should parse a valid JSON string into an object', () => {
            const result = readJson<typeof mockJsonObject>(mockFileName, mockJsonString);

            expect(result).toEqual(mockJsonObject);
        });

        it('should throw an error if JSON input is invalid', () => {
            expect(() => readJson(mockFileName, 'invalid json')).toThrow('Error processing JSON file test.json: Invalid JSON');
        });
    });

});
