Skip to content

Commit

Permalink
test(button): add tests for new aria attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sirrah-tam committed Dec 6, 2023
1 parent 6b216fc commit 4affa69
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions packages/pharos/src/components/button/pharos-button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ describe('pharos-button', () => {
await expect(component).to.be.accessible();
});

it('is accessible as an icon button', async () => {
component.icon = 'download';
component.a11yLabel = 'download';
it('is renders aria-label on button and is accessible', async () => {
const label = 'download';
component.icon = label;
component.a11yLabel = label;
await component.updateComplete;
await expect(
component.renderRoot.querySelector('button')?.getAttribute('aria-label')
).to.equal(label);
await expect(component).to.be.accessible();
});

Expand All @@ -37,6 +41,33 @@ describe('pharos-button', () => {
await expect(component).to.be.accessible();
});

it('is accessible when using aria-disabled', async () => {
component.a11yDisabled = 'true';
await component.updateComplete;
await expect(
component.renderRoot.querySelector('button')?.getAttribute('aria-disabled')
).to.equal('true');
await expect(component).to.be.accessible();
});

it('is accessible when using aria-expanded', async () => {
component.a11yExpanded = 'true';
await component.updateComplete;
await expect(
component.renderRoot.querySelector('button')?.getAttribute('aria-expanded')
).to.equal('true');
await expect(component).to.be.accessible();
});

it('is accessible when using aria-haspopup', async () => {
component.a11yHaspopup = 'menu';
await component.updateComplete;
await expect(
component.renderRoot.querySelector('button')?.getAttribute('aria-haspopup')
).to.equal('menu');
await expect(component).to.be.accessible();
});

it('is accessible as the secondary variant', async () => {
component.variant = 'secondary';
await component.updateComplete;
Expand Down

0 comments on commit 4affa69

Please sign in to comment.