Skip to content

Commit f80a3ae

Browse files
committed
[Tests] no-unused-prop-types, require-default-props: add passing tests
Closes #1197
1 parent 6eceb6b commit f80a3ae

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,40 @@ ruleTester.run('no-unused-prop-types', rule, {
38253825
`,
38263826
features: ['types'],
38273827
},
3828+
{
3829+
code: `
3830+
type Props = {
3831+
history: {
3832+
push: Function,
3833+
},
3834+
match?: {
3835+
params?: {
3836+
date?: string
3837+
},
3838+
},
3839+
};
3840+
3841+
export const Daily = ({ history, match: {
3842+
params: {
3843+
date = moment().toISOString(),
3844+
} = {},
3845+
} = {} }: Props) => (
3846+
<div>
3847+
<div style={{ textAlign: 'right', paddingRight: '25px' }}>
3848+
Show <DatePicker
3849+
selected={moment(date)}
3850+
className="datetime"
3851+
onChange={d => history.push(\`./\${d.toISOString()}\`)}
3852+
/>
3853+
</div>
3854+
<WithData url="/payments/daily" body={{ date: moment(date).toISOString() }}>
3855+
<Flashcards date={moment(date)} />
3856+
</WithData>
3857+
</div>
3858+
);
3859+
`,
3860+
features: ['types'],
3861+
},
38283862
]),
38293863

38303864
invalid: parsers.all([].concat(

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,5 +2589,47 @@ ruleTester.run('require-default-props', rule, {
25892589
},
25902590
],
25912591
},
2592+
{
2593+
code: `
2594+
type Props = {
2595+
history: {
2596+
push: Function,
2597+
},
2598+
match?: {
2599+
params?: {
2600+
date?: string
2601+
},
2602+
},
2603+
};
2604+
2605+
export const Daily = ({ history, match: {
2606+
params: {
2607+
date = moment().toISOString(),
2608+
} = {},
2609+
} = {} }: Props) => (
2610+
<div>
2611+
<div style={{ textAlign: 'right', paddingRight: '25px' }}>
2612+
Show <DatePicker
2613+
selected={moment(date)}
2614+
className="datetime"
2615+
onChange={d => history.push(\`./\${d.toISOString()}\`)}
2616+
/>
2617+
</div>
2618+
<WithData url="/payments/daily" body={{ date: moment(date).toISOString() }}>
2619+
<Flashcards date={moment(date)} />
2620+
</WithData>
2621+
</div>
2622+
);
2623+
`,
2624+
features: ['types'],
2625+
errors: [
2626+
{
2627+
messageId: 'shouldHaveDefault',
2628+
data: {
2629+
name: 'match',
2630+
},
2631+
},
2632+
],
2633+
},
25922634
]),
25932635
});

0 commit comments

Comments
 (0)