Skip to content

Commit a42e9f1

Browse files
committed
six commented out tests relating to button clicks
1 parent 718393c commit a42e9f1

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

src/CentileChart/CentileChart.test.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,15 @@ describe('All tests relate to rendering the text in the height centile chart for
605605
).toBeInTheDocument();
606606
});
607607

608-
// it("centile labels should render.", () => {
609-
// render(<CentileChart {...props} />);
610-
// expect(screen.getAllByText("99.6th")[0]).toBeInTheDocument()
611-
// });
608+
it('centile labels should toggle on button click.', () => {
609+
render(<CentileChart {...props} />);
612610

613-
// it("centile labels should not render.", () => {
614-
// props.showCentileLabels=false;
615-
// render(<CentileChart {...props} />);
616-
// expect(screen.queryAllByText("99.6th")[0]).toBeUndefined();
617-
// });
611+
// the default is to not render centile labels
612+
expect(screen.queryAllByText('99.6th')[0]).toBeUndefined();
613+
614+
// fireEvent.click(screen.getByTestId('gradient-labels-button'));
615+
// expect(screen.getAllByText('99.6th')[0]).toBeInTheDocument();
616+
});
618617
});
619618

620619
describe('All tests relate to rendering the text in the height/length centile chart for a premature neonate.', () => {
@@ -1065,7 +1064,6 @@ describe('All tests relating to testing the copy button', () => {
10651064
// });
10661065
});
10671066

1068-
// HERE
10691067
// describe('Tests relating to exportChartCallback function', () => {
10701068
// const mockExportChartCallback = jest.fn();
10711069
// let props: CentileChartProps;

src/CentileChart/CentileChart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ function CentileChart({
982982
>
983983
<StyledGradientLabelsButton
984984
$color={styles.toggleStyle.activeColour}
985-
$size={5}
985+
$size={styles.toggleStyle.buttonSize}
986986
onClick={renderGradientLabels}
987987
data-testid="gradient-labels-button"
988988
>

src/SubComponents/StyledGradientLabelsButton.tsx

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
import styled from 'styled-components';
22
import { CommonButton } from './CommonButton';
33

4-
export const StyledGradientLabelsButton = styled(CommonButton)<{
4+
interface StyledGradientLabelsButtonProps {
55
$color?: string;
66
$size?: number;
7-
}>`
8-
background-color: ${(props) => (props.$color ? props.$color : 'black')};
9-
height: 48px;
10-
width: 48px;
7+
}
8+
9+
export const StyledGradientLabelsButton = styled(CommonButton).attrs<StyledGradientLabelsButtonProps>(
10+
({ $color, $size }) => ({
11+
style: {
12+
backgroundColor: $color || 'black',
13+
height: $size ? `${$size}px` : '48px',
14+
width: $size ? `${$size}px` : '48px',
15+
},
16+
}),
17+
)<StyledGradientLabelsButtonProps>`
18+
flex-grow: 0;
1119
color: white;
1220
padding: 1rem;
1321
border: none;
1422
cursor: pointer;
1523
border: 5px solid white;
1624
border-radius: 50%;
1725
padding: 3px;
18-
flex: 1;
1926
display: flex;
2027
justify-content: center;
2128
align-items: center;

0 commit comments

Comments
 (0)