Skip to content

Commit

Permalink
[Highcharts] Improve tests & avoid warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfacq committed Sep 27, 2023
1 parent a6efeb9 commit 354f31b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ErrorBoundary from './ErrorBoundary'
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'

AccessibilityModule(Highcharts)
Highcharts.AST.allowedAttributes.push('rel');

const { Header, Content, Sider } = Layout

Expand Down
11 changes: 6 additions & 5 deletions src/Graph/__tests__/Download.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ api.downloads = vi.fn().mockImplementation(() => {
describe('Download component', () => {
test('renders correctly', async () => {
let getByText;
let queryAllByLabelText;
let queryAllByText;

await act(async () => {
({ getByText, queryAllByLabelText } = render(
({ getByText, queryAllByText } = render(
<Download />
));
setTimeout(() => { }, delay)
Expand All @@ -51,16 +51,17 @@ describe('Download component', () => {
expect(getByText('Adoptium Download Stats')).toBeInTheDocument();
expect(getByText('233 144 070')).toBeInTheDocument();

expect(queryAllByLabelText('Total Downloads').length).toBe(2);
expect(queryAllByText('Total Downloads', {selector: 'text'}).length).toBe(3);
expect(getByText('72 333 402')).toBeInTheDocument();
expect(getByText('160 810 668')).toBeInTheDocument();
expect(getByText('233 144 070')).toBeInTheDocument();

expect(queryAllByLabelText('Github Downloads').length).toBe(1);

expect(queryAllByText('Github Downloads', {selector: 'text'}).length).toBe(3);
expect(getByText('39 821 217')).toBeInTheDocument();
expect(getByText('48 300 842')).toBeInTheDocument();
expect(getByText('45 342 098')).toBeInTheDocument();
expect(getByText('594 778')).toBeInTheDocument();

expect(queryAllByText('JDK Versions', {selector: 'text'}).length).toBe(1);
});
});
4 changes: 4 additions & 0 deletions vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { vi } from 'vitest'
import Highcharts from 'highcharts'
import AccessibilityModule from 'highcharts/modules/accessibility'

AccessibilityModule(Highcharts)

Highcharts.useSerialIds(true);
Highcharts.AST.allowedAttributes.push('rel');

// mock router for 'useParams'
vi.mock('react-router-dom');
Expand Down

0 comments on commit 354f31b

Please sign in to comment.