import { StringRecordParser } from './string-record.parser'; describe('StringRecordParser', () => { const parser = new StringRecordParser(); it('parses a JSON object of string values', () => { expect(parser.parse('{"a":"1","b":"two"}')).toEqual({ a: '1', b: 'two' }); }); it('parses an empty object', () => { expect(parser.parse('{}')).toEqual({}); }); it('accepts an already-parsed object (e.g. default value)', () => { expect(parser.parse({ a: 'b' })).toEqual({ a: 'b' }); }); it('rejects invalid JSON', () => { expect(() => parser.parse('not json')).toThrow(); }); it('rejects non-object JSON (array, primitive, null)', () => { expect(() => parser.parse('["a","b"]')).toThrow(); expect(() => parser.parse('"a string"')).toThrow(); expect(() => parser.parse('42')).toThrow(); expect(() => parser.parse('null')).toThrow(); }); it('rejects objects with non-string values', () => { expect(() => parser.parse('{"a":1}')).toThrow(); expect(() => parser.parse('{"a":{"nested":"x"}}')).toThrow(); }); });