Skip to content

Commit ab64f95

Browse files
authored
test: adds aXe test for <SocialMedia /> (#508)
Unsure if this actually does anything (how does jest interact) with Font Awesome? Worth investigating.
1 parent d1453a0 commit ab64f95

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { render } from '@testing-library/react';
2+
import { axe, toHaveNoViolations } from 'jest-axe';
3+
import React from 'react';
4+
import { act } from 'react-dom/test-utils';
5+
import SocialMedia from '../../components/SocialMedia';
6+
7+
expect.extend(toHaveNoViolations);
8+
9+
describe('SocialMedia, dark text (default)', () => {
10+
it('has no axe violations', async () => {
11+
// this let / async construct is required since next/image rendering
12+
// is a side effect that needs to be captured with async act
13+
// see https://reactjs.org/docs/test-utils.html#act
14+
let results;
15+
await act(async () => {
16+
const { container } = render(<SocialMedia />);
17+
results = await axe(container);
18+
});
19+
expect(results).toHaveNoViolations();
20+
});
21+
});
22+
23+
describe('SocialMedia, light text', () => {
24+
it('has no axe violations', async () => {
25+
// this let / async construct is required since next/image rendering
26+
// is a side effect that needs to be captured with async act
27+
// see https://reactjs.org/docs/test-utils.html#act
28+
let results;
29+
await act(async () => {
30+
const { container } = render(<SocialMedia type="light" />);
31+
results = await axe(container);
32+
});
33+
expect(results).toHaveNoViolations();
34+
});
35+
});

0 commit comments

Comments
 (0)