Skip to content

Commit

Permalink
[tests]: add tests for component detection
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Aug 19, 2019
1 parent 439e2a8 commit aac7807
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/lib/rules/destructuring-assignment.js
Expand Up @@ -256,6 +256,29 @@ ruleTester.run('destructuring-assignment', rule, {
errors: [
{message: 'Must use destructuring props assignment'}
]
}, {
code: `
module.exports = {
Foo(props) {
return <p>{props.a}</p>;
}
}
`,
errors: [{message: 'Must use destructuring props assignment'}]
}, {
code: `
export default function Foo(props) {
return <p>{props.a}</p>;
}
`,
errors: [{message: 'Must use destructuring props assignment'}]
}, {
code: `
function hof() {
return (props) => <p>{props.a}</p>;
}
`,
errors: [{message: 'Must use destructuring props assignment'}]
}, {
code: `const Foo = class extends React.PureComponent {
render() {
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/display-name.js
Expand Up @@ -661,6 +661,18 @@ ruleTester.run('display-name', rule, {
errors: [{
message: 'Component definition is missing display name'
}]
}, {
code: `
function Hof() {
return function () {
return <div />
}
}
`,
parser: parsers.BABEL_ESLINT,
errors: [{
message: 'Component definition is missing display name'
}]
}, {
code: `
import React, { createElement } from "react";
Expand Down

0 comments on commit aac7807

Please sign in to comment.