From ac3d11ab4fcbaa94cd715b57f9b890fec6f811ba Mon Sep 17 00:00:00 2001 From: Johnny Zabala Date: Thu, 13 Aug 2020 09:57:13 -0400 Subject: [PATCH] [Test]: add more test cases for PropTypes.exact support --- tests/lib/rules/prop-types.js | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 17a9bf0d1c..bdd342a141 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -5848,6 +5848,49 @@ ruleTester.run('prop-types', rule, { errors: [{ message: "'foo.c' is missing in props validation" }] + }, + { + code: ` + function Zoo(props) { + return ( + <> + {props.foo.c} + + ); + } + + Zoo.propTypes = { + foo: React.PropTypes.exact({ + a: PropTypes.number, + b: PropTypes.number, + }), + }; + `, + errors: [{ + message: "'foo.c' is missing in props validation" + }] + }, + { + code: ` + function Zoo(props) { + return ( + <> + {props.foo.c} + + ); + } + + Zoo.propTypes = { + foo: Foo.PropTypes.exact({ + a: PropTypes.number, + b: PropTypes.number, + }), + }; + `, + settings, + errors: [{ + message: "'foo.c' is missing in props validation" + }] } ]) )