From ccbd46ba9d438a04971ece6d301a489c75297bf3 Mon Sep 17 00:00:00 2001 From: Eric Olkowski Date: Fri, 16 Aug 2024 10:51:52 -0400 Subject: [PATCH] Added test for 1 valid and 1 invalid property --- .../card-updated-clickable-markup.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/cardUpdatedClickableMarkup/card-updated-clickable-markup.test.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/cardUpdatedClickableMarkup/card-updated-clickable-markup.test.ts index d61619ae..01765df2 100644 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/cardUpdatedClickableMarkup/card-updated-clickable-markup.test.ts +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/cardUpdatedClickableMarkup/card-updated-clickable-markup.test.ts @@ -20,6 +20,7 @@ ruleTester.run("card-updated-clickable-markup", rule, { }, ], invalid: [ + // No invalid properties { code: `import { Card, CardHeader } from '@patternfly/react-core'; `, output: `import { Card, CardHeader } from '@patternfly/react-core'; `, @@ -30,6 +31,19 @@ ruleTester.run("card-updated-clickable-markup", rule, { }, ], }, + // 1 valid property + 1 invalid property + { + code: `import { Card, CardHeader } from '@patternfly/react-core'; `, + output: `import { Card, CardHeader } from '@patternfly/react-core'; `, + errors: [ + { + message: + "The markup for clickable-only cards has been updated.Additionally, the `selectableActions.selectableActionId` and `selectableActions.name` props are no longer necessary to pass to CardHeader for clickable-only cards.", + type: "JSXElement", + }, + ], + }, + // 2 invalid properties { code: `import { Card, CardHeader } from '@patternfly/react-core'; `, output: `import { Card, CardHeader } from '@patternfly/react-core'; `, @@ -41,6 +55,7 @@ ruleTester.run("card-updated-clickable-markup", rule, { }, ], }, + // 1 valid property + 2 invalid properties { code: `import { Card, CardHeader } from '@patternfly/react-core'; `, output: `import { Card, CardHeader } from '@patternfly/react-core'; `, @@ -53,6 +68,7 @@ ruleTester.run("card-updated-clickable-markup", rule, { }, ], }, + // Passed as a variable reference { code: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {name: 'Test', selectableActionId: 'Id'}; `, output: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {}; `, @@ -64,6 +80,7 @@ ruleTester.run("card-updated-clickable-markup", rule, { }, ], }, + // Passed as a variable reference with 2 valid and 2 invalid properties { code: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {to: "#", name: 'Test', extra: "thing", selectableActionId: 'Id'}; `, output: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {to: "#", extra: "thing"}; `,