Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the gradient labels button doesn't auto-submit a parent form #92

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/CentileChart/CentileChart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1175,4 +1175,36 @@ describe("Tests relating to negative settings on the zoom button", () => {
render(<CentileChart {...props} />);
expect(screen.queryByTestId('resetzoom-button')).not.toBeInTheDocument();
})
})

describe("Tests relating to the gradient labels button", () => {
let props: CentileChartProps;
const midparentalHeight: MidParentalHeightObject = {}

beforeEach(() => {
props = {
chartsVersion: "7.0.0",
reference: "uk-who",
title: "Term Girl",
subtitle: "Now over 4 years with advanced bone age",
measurementMethod: "height",
sex: 'female',
childMeasurements: termGirlWithSingleHeightMeasurementAndBoneAgeAndEvent,
midParentalHeightData: midparentalHeight,
enableZoom: true,
styles: monochromeStyles,
enableExport: false,
exportChartCallback: ()=>null,
clinicianFocus: false
};
});

it("should not trigger form submission when gradient labels clicked", () => {
const onSubmit = jest.fn();
render(<form onSubmit={onSubmit}>
<CentileChart {...props} />
</form>);
fireEvent.click(screen.getByTestId('gradient-labels-button'));
expect(onSubmit).not.toHaveBeenCalled();
});
})
3 changes: 2 additions & 1 deletion src/SubComponents/StyledGradientLabelsButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from 'styled-components';
import { CommonButton } from './CommonButton';

export const StyledGradientLabelsButton = styled.button<{
export const StyledGradientLabelsButton = styled(CommonButton)<{
$color?: string,
size?: number
}>`
Expand Down
Loading