From 34d82e1092608b55c6b0dca083c0447d19ff7d66 Mon Sep 17 00:00:00 2001 From: Jason Baker Date: Thu, 25 Jul 2024 15:52:23 +0000 Subject: [PATCH] test(icon): add attribute to type icon and update tests --- src/auro-toast.js | 23 +++++------ test/auro-toast.test.js | 86 +++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/auro-toast.js b/src/auro-toast.js index 855ebb3..600cce5 100644 --- a/src/auro-toast.js +++ b/src/auro-toast.js @@ -211,15 +211,16 @@ export class AuroToast extends LitElement { } render() { - return this.visible ? html`
- ${this.noIcon ? undefined : html` - <${this.iconTag} customSize customColor customSvg class="testing"> - ${this.variant === 'success' ? this.successSvg : undefined} - ${this.variant === 'error' ? this.errorSvg : undefined} - ${this.variant !== 'success' && this.variant !== 'error' ? this.infoSvg : undefined} - - `} -
+ return this.visible ? html` +
+ ${this.noIcon ? undefined : html` + <${this.iconTag} customSize customColor customSvg class="typeIcon"> + ${this.variant === 'success' ? this.successSvg : undefined} + ${this.variant === 'error' ? this.errorSvg : undefined} + ${this.variant !== 'success' && this.variant !== 'error' ? this.infoSvg : undefined} + + `} +
<${this.buttonTag} variant="flat" ?onDark=${this.getAttribute('variant') !== 'error' && this.getAttribute('variant') !== 'success'} @@ -229,8 +230,8 @@ export class AuroToast extends LitElement { Close -
` - : undefined; +
+ ` : undefined; } } diff --git a/test/auro-toast.test.js b/test/auro-toast.test.js index 4000af0..05ee618 100644 --- a/test/auro-toast.test.js +++ b/test/auro-toast.test.js @@ -2,60 +2,62 @@ import { fixture, html, expect, aTimeout, elementUpdated } from '@open-wc/testin import '../src/auro-toast'; describe('auro-toast', () => { - // it('auro-toast is accessible', async () => { - // const el = await fixture(html` - // - // `); + it('auro-toast is accessible', async () => { + const el = await fixture(html` + + `); - // await expect(el).to.be.accessible(); - // }); + await expect(el).to.be.accessible(); + }); - // it('auro-toast custom element is defined', async () => { - // const el = !!customElements.get("auro-toast"); + it('auro-toast custom element is defined', async () => { + const el = !!customElements.get("auro-toast"); - // expect(el).to.be.true; - // }); + expect(el).to.be.true; + }); - // it('close the toast when the X icon button is clicked on', async () => { - // const el = await fixture(html` - // Hello I am a toast! - // `); + it('close the toast when the X icon button is clicked on', async () => { + const el = await fixture(html` + Hello I am a toast! + `); - // const closeButton = el.shadowRoot.querySelector('[part="close-button"]'); - // closeButton.click(); + const closeButton = el.shadowRoot.querySelector('[part="close-button"]'); + closeButton.click(); - // setTimeout(() => expect(el.visible).to.be.false, 1000); - // }); + setTimeout(() => expect(el.visible).to.be.false, 1000); + }); - // it('auro-toast is hidden after five seconds', async () => { - // const el = await fixture(html` - // Something - // `); + it('auro-toast is hidden after five seconds', async () => { + const el = await fixture(html` + Something + `); - // await aTimeout(5500); - // const root = el.shadowRoot; + await aTimeout(5500); + const root = el.shadowRoot; - // expect(el.visible).to.be.false; - // }).timeout(6000); + expect(el.visible).to.be.false; + }).timeout(6000); - // it('error auro-toast should not auto dismiss', async () => { - // const el = await fixture(html` - // Something - // `); + it('error auro-toast should not auto dismiss', async () => { + const el = await fixture(html` + Something + `); - // await aTimeout(5050); - // const root = el.shadowRoot; - // const toastContainer = root.querySelector('.toastContainer'); + await aTimeout(5050); + const root = el.shadowRoot; + const toastContainer = root.querySelector('.toastContainer'); - // expect(el.visible).to.be.true; - // }).timeout(5060); + expect(el.visible).to.be.true; + }).timeout(5060); - // it('sets auro-toast to noIcon style', async () => { - // const el = await fixture(html` - // Success - // `); - // const root = el.shadowRoot; - // expect(root.querySelector('[auro-icon]')).to.not.exist; - // }); + it('sets auro-toast to noIcon style', async () => { + const el = await fixture(html` + Success + `); + const root = el.shadowRoot; + + console.warn(el.shadowRoot.querySelector('.typeIcon')); + expect(root.querySelector('.typeIcon')).to.not.exist; + }); });