Skip to content

Commit

Permalink
Added test for 1 valid and 1 invalid property
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye committed Aug 22, 2024
1 parent 7ae6100 commit ccbd46b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ruleTester.run("card-updated-clickable-markup", rule, {
},
],
invalid: [
// No invalid properties
{
code: `import { Card, CardHeader } from '@patternfly/react-core'; <Card isClickable><CardHeader selectableActions={{to: "#"}} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; <Card isClickable><CardHeader selectableActions={{to: "#"}} /></Card>`,
Expand All @@ -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'; <Card isClickable><CardHeader selectableActions={{to: '#', selectableActionId: 'Id'}} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; <Card isClickable><CardHeader selectableActions={{to: '#'}} /></Card>`,
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'; <Card isClickable><CardHeader selectableActions={{name: 'Test', selectableActionId: 'Id'}} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; <Card isClickable><CardHeader selectableActions={{}} /></Card>`,
Expand All @@ -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'; <Card isClickable><CardHeader selectableActions={{to: "#", name: 'Test', selectableActionId: 'Id'}} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; <Card isClickable><CardHeader selectableActions={{to: "#"}} /></Card>`,
Expand All @@ -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'}; <Card isClickable><CardHeader selectableActions={obj} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {}; <Card isClickable><CardHeader selectableActions={obj} /></Card>`,
Expand All @@ -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'}; <Card isClickable><CardHeader selectableActions={obj} /></Card>`,
output: `import { Card, CardHeader } from '@patternfly/react-core'; const obj = {to: "#", extra: "thing"}; <Card isClickable><CardHeader selectableActions={obj} /></Card>`,
Expand Down

0 comments on commit ccbd46b

Please sign in to comment.