From 30c24fa7aad768dd45e91e77ace345a4534efaf5 Mon Sep 17 00:00:00 2001 From: Luka Leer Date: Thu, 26 Dec 2024 02:31:25 +0100 Subject: [PATCH] fix(jsonc): do not check exact error messages --- src/jsonc.spec.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/jsonc.spec.ts b/src/jsonc.spec.ts index e1e2e654..4e506037 100644 --- a/src/jsonc.spec.ts +++ b/src/jsonc.spec.ts @@ -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); }); });