Skip to content

Commit 40ce3c8

Browse files
authored
Merge pull request #12 from NHSDigital/lp-fix-disable-default-behaviour-error
sp-fix Removed disableDefaultBehaviour from the list of rendered attr…
2 parents 71dfc88 + b5b36dc commit 40ce3c8

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/components/skip-link/SkipLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class SkipLink extends React.Component<SkipLinkProps> {
8484
};
8585

8686
render() {
87-
const { className, focusTargetRef, ...rest } = this.props;
87+
const { className, focusTargetRef, disableDefaultBehaviour, ...rest } = this.props;
8888
return (
8989
<a className={classNames('nhsuk-skip-link', className)} onClick={this.onClick} {...rest}></a>
9090
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, { createRef } from 'react';
2+
import { shallow } from 'enzyme';
3+
import SkipLink from '..';
4+
5+
describe('SkipLink', () => {
6+
it('matches snapshot', () => {
7+
const component = shallow(<SkipLink />);
8+
expect(component).toMatchSnapshot('SkipLink');
9+
component.unmount();
10+
});
11+
12+
it('does not add focusTargetRef or disableDefaultBehaviour as attributes when rendered', () => {
13+
const ref = createRef<HTMLElement>();
14+
const component = shallow(<SkipLink focusTargetRef={ref} disableDefaultBehaviour aria-label="test" />);
15+
expect(component.prop('focusTargetRef')).toBeUndefined();
16+
expect(component.prop('disableDefaultBehaviour')).toBeUndefined();
17+
expect(component.prop('aria-label')).toEqual('test');
18+
component.unmount();
19+
});
20+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`SkipLink matches snapshot: SkipLink 1`] = `
4+
<a
5+
className="nhsuk-skip-link"
6+
href="#maincontent"
7+
onClick={[Function]}
8+
>
9+
Skip to main content
10+
</a>
11+
`;

0 commit comments

Comments
 (0)