Skip to content

Commit 487d780

Browse files
committed
add test cover for Tag component
Signed-off-by: Winner95 <Winner95@users.noreply.github.com>
1 parent 77095c9 commit 487d780

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

__tests__/handler.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ describe('typescript-react-function-component-props-handler', () => {
131131
expect(doc.props.children.tsType.raw).toBe('React.ReactNode');
132132
});
133133

134+
test('handles React.FC<Props> components with type props', () => {
135+
const doc = parseFixture('Tag.tsx');
136+
137+
expect(doc).toHaveProperty('displayName');
138+
expect(doc.displayName).toBe('Tag');
139+
expect(doc).toHaveProperty('props');
140+
expect(doc.props).toHaveProperty('onRemove');
141+
expect(doc.props.onRemove.tsType.raw).toBe('() => void');
142+
});
143+
134144
// Line 31 in index.js without type - can't be tested directly because of early return
135145
test('handles components without type', () => {
136146
const doc = parseFixture('ComponentWithoutType.tsx');

fixtures/Tag.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
type TagProps = {
4+
type?: 'normal' | 'warning' | 'error' | 'info';
5+
onRemove?: () => void;
6+
isDisabled?: boolean;
7+
children?: React.ReactNode;
8+
};
9+
10+
export const Tag: React.FC<TagProps> = (props) => {
11+
return <>{props.children}</>;
12+
};

0 commit comments

Comments
 (0)