Skip to content

Commit

Permalink
test: switch serialiser tests to inline error snapshots (which they e…
Browse files Browse the repository at this point in the history
…ffectively were already)
  • Loading branch information
apaleslimghost committed Aug 10, 2023
1 parent 986a4d8 commit 21f2541
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions components/x-interaction/__tests__/serialiser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ describe('serialiser', () => {
it('throws Error if component is not registered in addData', () => {
jest.spyOn(registerComponent, 'getComponent').mockReturnValue(undefined)

expect(() => serialiser.addData('id', Component, {})).toThrow(
`a Serialiser's addData was called for an unregistered component. ensure you're registering your component before attempting to output the hydration data`
expect(() => serialiser.addData('id', Component, {})).toThrowErrorMatchingInlineSnapshot(
`"a Serialiser's addData was called for an unregistered testComponent component with id undefined. ensure you're registering your component before attempting to output the hydration data"`
)
})

it('throws Error if serialiser is destroyed in addData', () => {
serialiser.destroyed = true
jest.spyOn(registerComponent, 'getComponent').mockReturnValue(Component)

expect(() => serialiser.addData('id', Component, {})).toThrow(
`an interaction component was rendered after flushHydrationData was called. ensure you're outputting the hydration data after rendering every component`
expect(() => serialiser.addData('id', Component, {})).toThrowErrorMatchingInlineSnapshot(
`"a testComponent component was rendered after flushHydrationData was called. ensure you're outputting the hydration data after rendering every component"`
)
})

it('throws Error if serialiser is destroyed in flushHydrationData', () => {
serialiser.destroyed = true
expect(() => serialiser.flushHydrationData()).toThrow(
`a Serialiser's flushHydrationData was called twice. ensure you're not reusing a Serialiser between requests`
expect(() => serialiser.flushHydrationData()).toThrowErrorMatchingInlineSnapshot(
`"a Serialiser's flushHydrationData was called twice. ensure you're not reusing a Serialiser between requests"`
)
})

Expand Down

0 comments on commit 21f2541

Please sign in to comment.