Skip to content

Commit 4ae2fae

Browse files
committed
Add some extra tests for flow annotations
1 parent 55675c0 commit 4ae2fae

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

tests/lib/rules/require-default-props.js

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,76 @@ ruleTester.run('require-default-props', rule, {
518518

519519
//
520520
// with Flow annotations
521+
{
522+
code: [
523+
'type Props = {',
524+
' foo: string',
525+
'};',
526+
527+
'class Hello extends React.Component {',
528+
' props: Props;',
529+
530+
' render() {',
531+
' return <div>Hello {this.props.foo}</div>;',
532+
' }',
533+
'}'
534+
].join('\n'),
535+
parser: 'babel-eslint'
536+
},
537+
{
538+
code: [
539+
'type Props = {',
540+
' foo: string,',
541+
' bar?: string',
542+
'};',
543+
544+
'class Hello extends React.Component {',
545+
' props: Props;',
546+
547+
' render() {',
548+
' return <div>Hello {this.props.foo}</div>;',
549+
' }',
550+
'}',
551+
552+
'Hello.defaultProps = {',
553+
' bar: "bar"',
554+
'};'
555+
].join('\n'),
556+
parser: 'babel-eslint'
557+
},
558+
{
559+
code: [
560+
'class Hello extends React.Component {',
561+
' props: {',
562+
' foo: string,',
563+
' bar?: string',
564+
' };',
565+
566+
' render() {',
567+
' return <div>Hello {this.props.foo}</div>;',
568+
' }',
569+
'}',
570+
571+
'Hello.defaultProps = {',
572+
' bar: "bar"',
573+
'};'
574+
].join('\n'),
575+
parser: 'babel-eslint'
576+
},
577+
{
578+
code: [
579+
'class Hello extends React.Component {',
580+
' props: {',
581+
' foo: string',
582+
' };',
583+
584+
' render() {',
585+
' return <div>Hello {this.props.foo}</div>;',
586+
' }',
587+
'}'
588+
].join('\n'),
589+
parser: 'babel-eslint'
590+
},
521591
{
522592
code: [
523593
'function Hello(props: { foo?: string }) {',
@@ -1526,7 +1596,7 @@ ruleTester.run('require-default-props', rule, {
15261596
}]
15271597
},
15281598

1529-
// // UnionType
1599+
// UnionType
15301600
{
15311601
code: [
15321602
'function Hello(props: { one?: string } | { two?: string }) {',

0 commit comments

Comments
 (0)