Skip to content

Commit

Permalink
fix(jsonc): do not check exact error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtaran committed Dec 26, 2024
1 parent dbb794d commit 30c24fa
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/jsonc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,20 @@ describe('Tiny JSONC', () => {
it('throws on invalid input', () => {
const { prefix, suffix } = Fixtures.errors;

expect(() => JSONC.parse(prefix)).toThrow(
new SyntaxError(`Unexpected token 'i', "${prefix}" is not valid JSON`),
);
expect(() => JSONC.parse(suffix)).toThrow(
new SyntaxError(
'Unexpected non-whitespace character after JSON at position 4 (line 1 column 5)',
),
);
expect(() => JSONC.parse(prefix)).toThrow(SyntaxError);
expect(() => JSONC.parse(suffix)).toThrow(SyntaxError);
});

it('throws on insufficient input', () => {
const { comment, empty } = Fixtures.errors;

expect(() => JSONC.parse(comment)).toThrow(new SyntaxError('Unexpected end of JSON input'));
expect(() => JSONC.parse(empty)).toThrow(new SyntaxError('Unexpected end of JSON input'));
expect(() => JSONC.parse(comment)).toThrow(SyntaxError);
expect(() => JSONC.parse(empty)).toThrow(SyntaxError);
});

it('throws on multi-line strings', () => {
const { multiLineString } = Fixtures.errors;

expect(() => JSONC.parse(multiLineString)).toThrow(
new SyntaxError(
'Bad control character in string literal in JSON at position 33 (line 3 column 23)',
),
);
expect(() => JSONC.parse(multiLineString)).toThrow(SyntaxError);
});
});

0 comments on commit 30c24fa

Please sign in to comment.