Skip to content

Commit

Permalink
test: simplify error expectation in JSON parsing test
Browse files Browse the repository at this point in the history
  • Loading branch information
bent10 committed Mar 4, 2024
1 parent a1a34e1 commit 7512dcd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ it('should throw an error on shorthand identifiers', () => {

const result = jsonLoose(input, context)
expect(result).toEqual('{"foo"}')
expect(() => JSON.parse(result)).toThrowError(
/Unexpected token } in JSON at position/
)
expect(() => JSON.parse(result)).toThrowError()
})

it('should throw an error on rest identifiers', () => {
Expand All @@ -88,9 +86,7 @@ it('should throw an error on rest identifiers', () => {

const result = jsonLoose(input, context)
expect(result).toEqual('{..."[object Object]"}')
expect(() => JSON.parse(result)).toThrowError(
/Unexpected token . in JSON at position/
)
expect(() => JSON.parse(result)).toThrowError()
})

it('should throw an error on malformed input', () => {
Expand Down

0 comments on commit 7512dcd

Please sign in to comment.