Skip to content

Commit

Permalink
Updated rename tests to use newProp var
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye committed Jul 11, 2024
1 parent 8a3f723 commit 4c193ac
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ const validTests: ValidTests = [];
const invalidTests: InvalidTests = [];
for (const component in renames) {
for (const oldProp in renames[component]) {
const newProp = renames[component][oldProp];
validTests.push(createValidTest(`<${component} ${oldProp} />`));
validTests.push(
createValidTest(
`import { ${component} } from '@patternfly/react-core'; <${component} ${renames[component][oldProp]} />`
`import { ${component} } from '@patternfly/react-core'; <${component} ${newProp} />`
)
);

const newProp = renames[component][oldProp];
const createMessage = (name: string = component) =>
`${oldProp} prop for ${name} has been renamed to ${newProp}`;
invalidTests.push(
createInvalidTest(
`import { ${component} } from '@patternfly/react-core'; <${component} ${oldProp} />`,
`import { ${component} } from '@patternfly/react-core'; <${component} ${renames[component][oldProp]} />`,
`import { ${component} } from '@patternfly/react-core'; <${component} ${newProp} />`,
[
{
message: createMessage(),
Expand All @@ -65,7 +65,7 @@ for (const component in renames) {
invalidTests.push(
createInvalidTest(
`import { ${component} } from '@patternfly/react-core'; <${component} ${oldProp}="test" />`,
`import { ${component} } from '@patternfly/react-core'; <${component} ${renames[component][oldProp]}="test" />`,
`import { ${component} } from '@patternfly/react-core'; <${component} ${newProp}="test" />`,
[
{
message: createMessage(),
Expand All @@ -77,7 +77,7 @@ for (const component in renames) {
invalidTests.push(
createInvalidTest(
`import { ${component} as CustomThing } from '@patternfly/react-core'; <CustomThing ${oldProp} />`,
`import { ${component} as CustomThing } from '@patternfly/react-core'; <CustomThing ${renames[component][oldProp]} />`,
`import { ${component} as CustomThing } from '@patternfly/react-core'; <CustomThing ${newProp} />`,
[
{
message: createMessage("CustomThing"),
Expand All @@ -89,7 +89,7 @@ for (const component in renames) {
invalidTests.push(
createInvalidTest(
`import { ${component} } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; <${component} ${oldProp} />`,
`import { ${component} } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; <${component} ${renames[component][oldProp]} />`,
`import { ${component} } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; <${component} ${newProp} />`,
[
{
message: createMessage(),
Expand All @@ -101,7 +101,7 @@ for (const component in renames) {
invalidTests.push(
createInvalidTest(
`import { ${component} } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; <${component} ${oldProp} />`,
`import { ${component} } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; <${component} ${renames[component][oldProp]} />`,
`import { ${component} } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; <${component} ${newProp} />`,
[
{
message: createMessage(),
Expand All @@ -113,7 +113,7 @@ for (const component in renames) {
invalidTests.push(
createInvalidTest(
`import { ${component} } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; <${component} ${oldProp} />`,
`import { ${component} } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; <${component} ${renames[component][oldProp]} />`,
`import { ${component} } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; <${component} ${newProp} />`,
[
{
message: createMessage(),
Expand Down

0 comments on commit 4c193ac

Please sign in to comment.