Skip to content

Commit

Permalink
test(icon-button): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
didimmova committed Sep 27, 2022
1 parent efe4b22 commit 4aa6213
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 40 deletions.
65 changes: 26 additions & 39 deletions src/components/button/icon-button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,36 @@ describe('IconButton component', () => {

it('renders a button element internally', async () => {
await expect(el).shadowDom.to.be.accessible();
expect(el).shadowDom.to.equal(
`<button><slot><igc-icon></igc-icon></slot></button>`,
{
ignoreAttributes: [
'variant',
'aria-label',
'aria-disabled',
'aria-hidden',
'part',
'role',
'size',
],
}
);
expect(el).shadowDom.to.equal(`<button><slot></slot></button>`, {
ignoreAttributes: [
'variant',
'aria-label',
'aria-disabled',
'aria-hidden',
'part',
'role',
'size',
],
});
});

it('renders an anchor element internally', async () => {
el.href = 'https://test.com';
await elementUpdated(el);

await expect(el).shadowDom.to.be.accessible();
expect(el).shadowDom.to.equal(
`<a><slot><igc-icon></igc-icon></slot></a>`,
{
ignoreAttributes: [
'variant',
'aria-label',
'aria-disabled',
'aria-hidden',
'part',
'role',
'size',
'href',
],
}
);
expect(el).shadowDom.to.equal(`<a><slot></slot></a>`, {
ignoreAttributes: [
'variant',
'aria-label',
'aria-disabled',
'aria-hidden',
'part',
'role',
'size',
'href',
],
});
});

it('is created with the proper default values', async () => {
Expand All @@ -82,9 +76,7 @@ describe('IconButton component', () => {

expect(el).shadowDom.to.equal(
`<button>
<slot>
<igc-icon name="${el.name}" collection="${el.collection}"></igc-icon>
</slot>
<igc-icon name="${el.name}" collection="${el.collection}"></igc-icon>
</button>`,
{
ignoreAttributes: [
Expand All @@ -106,9 +98,7 @@ describe('IconButton component', () => {

expect(el).shadowDom.to.equal(
`<button>
<slot>
<igc-icon mirrored></igc-icon>
</slot>
<igc-icon mirrored></igc-icon>
</button>`,
{
ignoreAttributes: [
Expand Down Expand Up @@ -171,7 +161,6 @@ describe('IconButton component', () => {
expect(el).shadowDom.to.equal(
`<button disabled>
<slot>
<igc-icon></igc-icon>
</slot>
</button>`,
{
Expand Down Expand Up @@ -204,9 +193,7 @@ describe('IconButton component', () => {
);
expect(el).shadowDom.to.equal(
`<a href="https://test.com" target="_blank" download="test" rel="test">
<slot>
<igc-icon name="biking" collection="default"></igc-icon>
</slot>
<igc-icon name="biking" collection="default"></igc-icon>
</a>`,
DIFF_OPTIONS
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/icon-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class IgcIconButtonComponent extends IgcButtonBaseComponent {

protected renderContent() {
return html`
${this.name
${this.name || this.mirrored
? html`<igc-icon
part="icon"
name=${ifDefined(this.name)}
Expand Down

0 comments on commit 4aa6213

Please sign in to comment.