const ruleTester = require("../../ruletester");
import * as rule from "./toolbarLabelGroupContent-updated-markup";
import {
ValidTests,
InvalidTests,
createInvalidTest,
createValidTest,
} from "../../helpers/testHelpers";
const applicableProps: string[] = [
"numberOfFilters",
"showClearFiltersButton",
"customLabelGroupContent",
];
const message =
"The markup for ToolbarLabelGruopContent has changed when numberOfFilters is greater than 0, showClearFilterButton is true, or customLabelGroupContent is passed.";
const errorObject = {
message,
type: "JSXOpeningElement",
};
const validTests: ValidTests = [];
const invalidTests: InvalidTests = [];
for (const prop of applicableProps) {
validTests.push(createValidTest(``));
validTests.push(
createValidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core'; `
)
);
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core'; `,
`import { ToolbarLabelGroupContent } from '@patternfly/react-core'; `,
[errorObject]
)
);
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent as CustomThing } from '@patternfly/react-core'; `,
`import { ToolbarLabelGroupContent as CustomThing } from '@patternfly/react-core'; `,
[errorObject]
)
);
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; `,
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/esm/components/Toolbar/index.js'; `,
[errorObject]
)
);
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; `,
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/js/components/Toolbar/index.js'; `,
[errorObject]
)
);
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; `,
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; `,
[errorObject]
)
);
}
invalidTests.push(
createInvalidTest(
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; `,
`import { ToolbarLabelGroupContent } from '@patternfly/react-core/dist/dynamic/components/Toolbar/index.js'; `,
[errorObject]
)
);
ruleTester.run("toolbarLabelGroupContent-updated-markup", rule, {
valid: validTests,
invalid: invalidTests,
});