Skip to content

Commit 100fee6

Browse files
committed
Add missing test for defaultProps
1 parent cd3772f commit 100fee6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/__tests__/visitor.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,16 @@ describe('visitElement', () => {
324324
expect(children[0].type).toBe(Noop)
325325
expect(children[0].props.children).toBe('test')
326326
})
327+
328+
it('renders function components with default props', () => {
329+
const Test = props => <Noop>{props.value}</Noop>
330+
331+
Test.defaultProps = { value: 'default' }
332+
333+
const childA = visitElement(<Test />, [], () => {})[0]
334+
expect(childA.props.children).toBe('default')
335+
336+
const childB = visitElement(<Test value="test" />, [], () => {})[0]
337+
expect(childB.props.children).toBe('test')
338+
})
327339
})

0 commit comments

Comments
 (0)