Skip to content

Commit

Permalink
test(cv-link): add tests for a11y (#1539)
Browse files Browse the repository at this point in the history
* test(cv-link): add tests for a11y

* test: fix a11y cv link test
  • Loading branch information
halivert authored Nov 1, 2023
1 parent 64fdaa5 commit 688af4e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/CvLink/CvLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
]"
>
<slot></slot>
<CvSvg v-if="icon" :class="`${carbonPrefix}--link__icon`" :svg="icon" />
<CvSvg
v-if="icon"
:class="`${carbonPrefix}--link__icon`"
:svg="icon"
alt=""
/>
</component>
</template>

Expand Down
34 changes: 34 additions & 0 deletions src/components/CvLink/__tests__/CvLink.accessibility.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { CvLink } from '..';
import { render } from '@testing-library/vue';

describe('CvLink - accessibility', () => {
it('CvLink - basic', async () => {
const main = document.createElement('main');
const result = render(CvLink, {
container: document.body.appendChild(main),
slots: { default: 'test link' },
});
await expect(result.container).toBeAccessible('cv-link');
}, 10000);

it('CvLink - disabled', async () => {
const main = document.createElement('main');
const result = render(CvLink, {
container: document.body.appendChild(main),
slots: { default: 'test link' },
props: { disabled: true },
});

await expect(result.container).toBeAccessible('cv-link');
}, 10000);

it('CvLink - with icon', async () => {
const main = document.createElement('main');
const result = render(CvLink, {
container: document.body.appendChild(main),
slots: { default: 'test link' },
props: { icon: 'Bee20' },
});
await expect(result.container).toBeAccessible('cv-link');
}, 10000);
});

0 comments on commit 688af4e

Please sign in to comment.