Skip to content
Snippets Groups Projects
Verified Commit f09a8533 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

FIX: ActionButtonItem.disabled not working #28

parent 3d221fe4
No related branches found
No related tags found
No related merge requests found
...@@ -79,8 +79,15 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = ( ...@@ -79,8 +79,15 @@ const DropzoneButtons: React.FC<DropzoneButtonsProps> = (
(actionButtonProps: ActionButtonItem, index: number) => { (actionButtonProps: ActionButtonItem, index: number) => {
const { children, label, resetStyles, className, style, onClick } = const {
actionButtonProps; disabled,
children,
label,
resetStyles,
className,
style,
onClick,
} = actionButtonProps;
return ( return (
<MaterialButton <MaterialButton
key={index} key={index}
......
...@@ -8,3 +8,27 @@ test("Validate label text must be 'Drop yor files here...'", () => { ...@@ -8,3 +8,27 @@ test("Validate label text must be 'Drop yor files here...'", () => {
render(<Dropzone> Drop yor files here...</Dropzone>); render(<Dropzone> Drop yor files here...</Dropzone>);
expect(screen.getByText("Drop yor files here...")).toBeInTheDocument(); expect(screen.getByText("Drop yor files here...")).toBeInTheDocument();
}); });
describe("Dropzone actionButtons", () => {
test.each([
[{ uploadButton: { onClick: console.log } }, false],
[{ uploadButton: { onClick: console.log, disabled: false } }, false],
[{ uploadButton: { onClick: console.log, disabled: true } }, true],
[{ deleteButton: { onClick: console.log } }, false],
[{ deleteButton: { onClick: console.log, disabled: false } }, false],
[{ deleteButton: { onClick: console.log, disabled: true } }, true],
// abortButton and cleanButton need more interaction
])("disabled %s -> %s", (config, expected) => {
const { container } = render(
<Dropzone actionButtons={{ position: "after", ...config }} />,
);
expect(
(
container.querySelector(
".files-ui-buttons-container button",
) as HTMLInputElement
).disabled,
).toBe(expected);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment