const ruleTester = require("../../ruletester"); import * as rule from "./button-moveIcons-icon-prop"; ruleTester.run("button-moveIcons-icon-prop", rule, { valid: [ { code: ``, }, { code: `import { Button } from '@patternfly/react-core'; `, }, ], invalid: [ { code: `import { Button } from '@patternfly/react-core'; const icon = Some icon; `, output: `import { Button } from '@patternfly/react-core'; const icon = Some icon; `, output: `import { Button } from '@patternfly/react-core'; `, output: `import { Button, ButtonVariant } from '@patternfly/react-core'; `, output: `import { Button } from '@patternfly/react-core/dist/esm/components/Button/index.js'; `, output: `import { Button } from '@patternfly/react-core/dist/js/components/Button/index.js'; `, output: `import { Button } from '@patternfly/react-core/dist/dynamic/components/Button/index.js'; `, output: `import { Button, Icon } from '@patternfly/react-core'; `, errors: [ { message: `Icons must now be passed to the \`icon\` prop of Button instead of as children. If you are passing anything other than an icon as children, ignore this rule when running fixes.`, type: "JSXElement", }, ], }, // with Icon component child (aliased) { code: `import { Button, Icon as PFIcon } from '@patternfly/react-core'; `, output: `import { Button, Icon as PFIcon } from '@patternfly/react-core'; `, errors: [ { message: `Icons must now be passed to the \`icon\` prop of Button instead of as children. If you are passing anything other than an icon as children, ignore this rule when running fixes.`, type: "JSXElement", }, ], }, // with react-icons icon child { code: `import { Button } from '@patternfly/react-core'; import { SomeIcon } from "@patternfly/react-icons"; `, output: `import { Button } from '@patternfly/react-core'; import { SomeIcon } from "@patternfly/react-icons"; `, errors: [ { message: `Icons must now be passed to the \`icon\` prop of Button instead of as children. If you are passing anything other than an icon as children, ignore this rule when running fixes.`, type: "JSXElement", }, ], }, // with react-icons icon child and another child { code: `import { Button } from '@patternfly/react-core'; import { SomeIcon } from "@patternfly/react-icons"; `, output: `import { Button } from '@patternfly/react-core'; import { SomeIcon } from "@patternfly/react-icons"; `, errors: [ { message: `Icons must now be passed to the \`icon\` prop of Button instead of as children. If you are passing anything other than an icon as children, ignore this rule when running fixes.`, type: "JSXElement", }, ], }, // with children prop { code: `import { Button } from '@patternfly/react-core';