Skip to content

Commit 8d6c460

Browse files
authored
CCM-8873 Accessibility improvements for markdown examples (#411)
1 parent aebb45a commit 8d6c460

File tree

17 files changed

+987
-125
lines changed

17 files changed

+987
-125
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { render } from '@testing-library/react';
2+
import CodeExample from '@atoms/CodeExample/CodeExample';
3+
4+
describe('CodeExample component', () => {
5+
it('renders component correctly', () => {
6+
const container = render(
7+
<CodeExample ariaId='test-id' ariaText='This is an example of markdown:'>
8+
# A test example
9+
</CodeExample>
10+
);
11+
12+
expect(container.asFragment()).toMatchSnapshot();
13+
});
14+
15+
it('renders component correctly when optional class is provided', () => {
16+
const container = render(
17+
<CodeExample
18+
ariaId='test-id'
19+
ariaText='This is an example of markdown:'
20+
codeClassName='test-class'
21+
>
22+
# A test example
23+
</CodeExample>
24+
);
25+
26+
expect(container.asFragment()).toMatchSnapshot();
27+
});
28+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CodeExample component renders component correctly 1`] = `
4+
<DocumentFragment>
5+
<span
6+
class="nhsuk-u-visually-hidden"
7+
id="test-id"
8+
>
9+
This is an example of markdown:
10+
</span>
11+
<code
12+
aria-describedby="test-id"
13+
>
14+
# A test example
15+
</code>
16+
</DocumentFragment>
17+
`;
18+
19+
exports[`CodeExample component renders component correctly when optional class is provided 1`] = `
20+
<DocumentFragment>
21+
<span
22+
class="nhsuk-u-visually-hidden"
23+
id="test-id"
24+
>
25+
This is an example of markdown:
26+
</span>
27+
<code
28+
aria-describedby="test-id"
29+
class="test-class"
30+
>
31+
# A test example
32+
</code>
33+
</DocumentFragment>
34+
`;

0 commit comments

Comments
 (0)