From 1e34758d2dfc5b315a954d8ea261f6c72c6ce09b Mon Sep 17 00:00:00 2001 From: Karolina Benitez Date: Wed, 26 Aug 2020 16:28:23 -0700 Subject: [PATCH] Adds tests --- tests/lib/rules/prefer-read-only-props.js | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/lib/rules/prefer-read-only-props.js b/tests/lib/rules/prefer-read-only-props.js index 9445605c68..f1bc224a38 100644 --- a/tests/lib/rules/prefer-read-only-props.js +++ b/tests/lib/rules/prefer-read-only-props.js @@ -131,6 +131,37 @@ ruleTester.run('prefer-read-only-props', rule, { name: PropTypes.string, }; ` + }, + { + // Class component with typed props argument + code: ` + type Props = $ReadOnly<{ + name: string, + }> + + class Hello extends React.Component { + render () { + return
Hello {this.props.name}
; + } + } + `, + parser: parsers.BABEL_ESLINT + }, + { + // Class component with typed props argument + code: ` + type Props = $ReadOnly<{ + +firstName: string, + lastName: string + }> + + class Hello extends React.Component { + render () { + return
Hello {this.props.firstName} {this.props.lastName}
; + } + } + `, + parser: parsers.BABEL_ESLINT } ],