Skip to content

Commit 79e2d0e

Browse files
committed
add test cases
1 parent 8e4d17a commit 79e2d0e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/lib/rules/function-component-definition.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,45 @@ ruleTester.run('function-component-definition', rule, {
406406
`,
407407
options: [{ unnamedComponents: ['arrow-function', 'function-expression'] }],
408408
},
409+
{
410+
// should not report non-jsx components
411+
code: `
412+
export default (key, subTree = {}) => {
413+
return (state) => {
414+
const dataInStore = getFromDataModel(key)(state);
415+
const fullPaths = dataInStore.map((item, index) => {
416+
return [key, index];
417+
});
418+
419+
return {
420+
key,
421+
paths: fullPaths.map((p) => [p[1]]),
422+
fullPaths,
423+
subTree: Object.keys(subTree).length ? subTree : null,
424+
}
425+
};
426+
}
427+
`,
428+
},
429+
{
430+
// should not report non-jsx components
431+
code: `
432+
function mapStateToProps() {
433+
const internItems = makeInternArray();
434+
const internClassList = makeInternArray();
435+
436+
return (state, props) => {
437+
const { store, bucket, singleCharacter } = props;
438+
439+
return {
440+
store: null,
441+
destinyVersion: store.destinyVersion,
442+
storeId: store.id,
443+
}
444+
}
445+
}
446+
`,
447+
},
409448
]),
410449

411450
invalid: parsers.all([

0 commit comments

Comments
 (0)