Skip to content

Commit 7a008eb

Browse files
committed
most tests fixed, 4 left
1 parent 0764e56 commit 7a008eb

File tree

14 files changed

+31
-21
lines changed

14 files changed

+31
-21
lines changed

src/components/content-presentation/table/TableHelpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Children, isValidElement, ReactElement, ReactNode } from 'react';
2-
import TableCell from './components/TableCell';
2+
import TableCell, { TableCellProps } from './components/TableCell';
33

4-
export const isTableCell = (child: ReactNode): child is ReactElement => {
4+
export const isTableCell = (child: ReactNode): child is ReactElement<TableCellProps> => {
55
return isValidElement(child) && child.type === TableCell;
66
};
77

88
export const getHeadingsFromChildren = (children: ReactNode): string[] => {
99
const headings: string[] = [];
1010
Children.map(children, (child) => {
11-
if (isTableCell(child)) {
11+
if (isTableCell(child) && child.props.children != null) {
1212
headings.push(child.props.children.toString());
1313
}
1414
});

src/components/content-presentation/table/components/__tests__/__snapshots__/TableBody.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Table.Body matches snapshot 1`] = `
44
<div>

src/components/content-presentation/table/components/__tests__/__snapshots__/TableCell.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Table.Cell matches snapshot 1`] = `
44
<div>

src/components/content-presentation/table/components/__tests__/__snapshots__/TableHead.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Table.Head matches snapshot 1`] = `
44
<div>

src/components/content-presentation/table/components/__tests__/__snapshots__/TableRow.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Table.Row matches snapshot 1`] = `
44
<div>

src/components/form-elements/button/Button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const useDebounceTimeout = (
3838
fn?: EventHandler<SyntheticEvent>,
3939
timeout: number = DefaultButtonDebounceTimeout,
4040
) => {
41-
const timeoutRef = useRef<number>(0);
41+
const timeoutRef = useRef<number | undefined>(0);
4242

4343
if (!fn) return undefined;
4444

@@ -148,7 +148,8 @@ export const ButtonLink: FC<ButtonLinkProps> = ({
148148
);
149149
};
150150

151-
const ButtonWrapper: FC<ButtonLinkProps | ButtonProps> = ({ href, as, ...rest }) => {
151+
const ButtonWrapper: FC<ButtonLinkProps | ButtonProps> = ({ as, ...rest }) => {
152+
const { href } = rest as ButtonLinkProps;
152153
if (as === 'a') {
153154
return <ButtonLink href={href} {...(rest as ButtonLinkProps)} />;
154155
}

src/components/form-elements/button/__tests__/__snapshots__/Button.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Button disabled matches snapshot: DisabledButton 1`] = `
44
<div>
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
import React, { FC } from 'react';
1+
import React, { ElementType, FC } from 'react';
22
import classNames from 'classnames';
33
import { AsElementLink } from '@util/types/LinkTypes';
44

5-
const CardLink: FC<AsElementLink<'a'>> = ({
5+
interface CardLinkProps extends AsElementLink {
6+
className?: string;
7+
}
8+
9+
const CardLink: FC<CardLinkProps> = ({
610
className,
711
asElement: Component = 'a',
812
...rest
9-
}) => <Component className={classNames('nhsuk-card__link', className)} {...rest} />;
13+
}) => {
14+
const Comp = Component as ElementType;
15+
return <Comp className={classNames('nhsuk-card__link', className)} {...rest} />;
16+
};
1017

1118
export default CardLink;

src/components/navigation/footer/Footer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const FooterList: FC<FooterListProps> = ({
1515

1616
if (singleColumn) {
1717
newChildren = Children.map(newChildren, (child) =>
18-
childIsOfComponentType(child, FooterListItem) ? cloneElement(child, { singleColumn }) : child,
18+
childIsOfComponentType(child, FooterListItem) ? cloneElement(child as any, { singleColumn }) : child,
1919
);
2020
}
2121

@@ -51,7 +51,7 @@ interface FooterProps extends HTMLProps<HTMLDivElement> {
5151

5252
interface Footer extends FC<FooterProps> {
5353
List: FC<FooterListProps>;
54-
ListItem: FC<HTMLProps<HTMLAnchorElement>>;
54+
ListItem: FC<HTMLProps<HTMLAnchorElement> & { singleColumn?: boolean }>;
5555
Copyright: FC<HTMLProps<HTMLParagraphElement>>;
5656
}
5757

@@ -74,7 +74,7 @@ const Footer: Footer = ({ className, children, visuallyHiddenText = 'Support lin
7474
} else {
7575
newChildren = Children.map(children, (child) =>
7676
childIsOfComponentType(child, FooterList)
77-
? cloneElement(child, { singleColumn: true })
77+
? cloneElement(child as any, { singleColumn: true })
7878
: child,
7979
);
8080
}

src/components/navigation/footer/__tests__/__snapshots__/Footer.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Footer Footer.Copyright matches snapshot: Footer.Copyright 1`] = `
44
<div>

0 commit comments

Comments
 (0)