Skip to content

Commit

Permalink
Add tests for screen reader table
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed May 7, 2024
1 parent 0dad1a5 commit 2c5297c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/__tests__/ChartScreenReaderTable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {describe, it, expect} from 'vitest';
import {mount} from '@vue/test-utils';
import ChartScreenReaderTable from '@/components/ChartScreenReaderTable.vue';

describe('ChartScreenReaderTable', () => {
it('mounts', () => {
const wrapper = mount(ChartScreenReaderTable, {
props: {
title: 'Amount of trainings',
id: 'my-chart',
labels: ['Running', 'Sprint', 'Swimming'],
data: [1, 2, 3],
},
});
expect(wrapper.html()).toMatchSnapshot();
expect(wrapper.find('table').classes()).toContain('d-sr-only');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`ChartScreenReaderTable > mounts 1`] = `
"<table class="d-sr-only" id="my-chart">
<caption>Amount of trainings</caption>
<thead>
<tr>
<th>Running</th>
<th>Sprint</th>
<th>Swimming</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>"
`;

0 comments on commit 2c5297c

Please sign in to comment.