Skip to content

Commit b457375

Browse files
committed
test: add test for ExperimentalRestProperty
Adds new test to handle case where the properties from an ObjectPatter are assigned to an ExperimentalRestProperty before spreading it in the result of mapStateToProps.
1 parent 8d51b9d commit b457375

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,41 @@ ruleTester.run('no-unused-prop-types', rule, {
9696
myProp: PropTypes.string.isRequired
9797
};
9898
99+
export default connect(mapStateToProps)(MyComponent);`,
100+
`const selectorFoo = (state) => ({isFetching: false, name: 'Foo', isDeleting: false, deltedId: ''});
101+
const selectorBar = (state) => ({ isFetching: false, name: 'Bar'});
102+
export const mapStateToProps = (state) => {
103+
const { isFetching: isFetchingFoo, ...restFoo } = selectorFoo(state);
104+
const { isFetching: isFeatchingBar, ...restBar } = selectorBar(state);
105+
return {
106+
isFetchingFoo,
107+
isFetchingBar,
108+
...restFoo,
109+
...restBar,
110+
};
111+
};
112+
export class MyComponent extends Component {
113+
render() {
114+
const {isFetchingFoo, name, isFetchingBar, isDeleting, deletedId} = this.props;
115+
return (
116+
<div>
117+
<span>{isFetchingFoo}</span>
118+
<span>{isDeleting}</span>
119+
<span>{isFetchingBar}</span>
120+
<span>{name}{deletedId}</span>
121+
</div>
122+
)
123+
}
124+
};
125+
126+
MyComponent.propTypes = {
127+
isFetchingFoo: PropTypes.bool.isRequired,
128+
isDeleting: PropTypes.bool.isRequired,
129+
deletedId: PropTypes.number.isRequired,
130+
name: Proptypes.string.isRequired,
131+
isFetchingBar: PropTypes.bool.isRequired,
132+
};
133+
99134
export default connect(mapStateToProps)(MyComponent);`,
100135
],
101136
invalid: [{

0 commit comments

Comments
 (0)