Skip to content

Commit

Permalink
Fixup unit tests for isSerializableProps
Browse files Browse the repository at this point in the history
  • Loading branch information
arturmuller committed Mar 15, 2021
1 parent e896570 commit 55b8d8d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions test/unit/is-serializable-props.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,34 @@ describe('isSerializableProps', () => {
expect(() => isSerializableProps('/', 'test', null))
.toThrowErrorMatchingInlineSnapshot(`
"Error serializing props returned from \`test\` in \\"/\\".
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\`."
`)
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\` (received: \`[object Null]\`)."
`)

expect(() => isSerializableProps('/', 'test', undefined))
.toThrowErrorMatchingInlineSnapshot(`
"Error serializing props returned from \`test\` in \\"/\\".
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\`."
`)
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\` (received: \`[object Undefined]\`)."
`)
})

it('handles non-plain object props', () => {
expect(() => isSerializableProps('/', 'test', []))
.toThrowErrorMatchingInlineSnapshot(`
"Error serializing props returned from \`test\` in \\"/\\".
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\` (received: \`[object Array]\`)."
`)

expect(() => isSerializableProps('/', 'test', class Foobar {}))
.toThrowErrorMatchingInlineSnapshot(`
"Error serializing props returned from \`test\` in \\"/\\".
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\` (received: \`[object Function]\`)."
`)

expect(() => isSerializableProps('/', 'test', function Foobar() {}))
.toThrowErrorMatchingInlineSnapshot(`
"Error serializing props returned from \`test\` in \\"/\\".
Reason: Props must be returned as a plain object from test: \`{ props: { ... } }\` (received: \`[object Function]\`)."
`)
})

it('allows empty props', () => {
Expand Down

0 comments on commit 55b8d8d

Please sign in to comment.