From aadfddb8e92136e78c577fb70e0f9c2c1ee176b9 Mon Sep 17 00:00:00 2001 From: Najika Yoo Date: Mon, 4 Oct 2021 12:35:14 -0700 Subject: [PATCH] fix(action-group): allow quiet and emphasized attributes to be passed to slotted action buttons --- .../action-group/test/action-group.test.ts | 106 +++++++++++++----- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/packages/action-group/test/action-group.test.ts b/packages/action-group/test/action-group.test.ts index 669b1dde94..19a9bb1b3c 100644 --- a/packages/action-group/test/action-group.test.ts +++ b/packages/action-group/test/action-group.test.ts @@ -36,6 +36,30 @@ import { import { sendKeys } from '@web/test-runner-commands'; import '../sp-action-group.js'; +class QuietActionGroup extends LitElement { + protected render(): TemplateResult { + return html` + + + + + `; + } +} +customElements.define('quiet-action-group', QuietActionGroup); + +class EmphasizedActionGroup extends LitElement { + protected render(): TemplateResult { + return html` + + + + + `; + } +} +customElements.define('emphasized-action-group', EmphasizedActionGroup); + describe('ActionGroup', () => { it('loads empty action-group accessibly', async () => { const el = await fixture( @@ -86,28 +110,16 @@ describe('ActionGroup', () => { expect(secondButton.quiet).to.be.true; }); it('applies `quiet` attribute to its slotted children', async () => { - class ActionGroupTestEl extends LitElement { - protected render(): TemplateResult { - return html` - - - - - `; - } - } - customElements.define('action-group-test-el', ActionGroupTestEl); - const el = await fixture( html` - + First Second - + ` ); const firstButton = el.querySelector('#first') as ActionButton; @@ -121,18 +133,6 @@ describe('ActionGroup', () => { expect(secondButton.quiet).to.be.true; }); it('applies `emphasized` attribute to its slotted children', async () => { - class EmphasizedActionGroup extends LitElement { - protected render(): TemplateResult { - return html` - - - - - `; - } - } - customElements.define('emphasized-action-group', EmphasizedActionGroup); - const el = await fixture( html` @@ -155,6 +155,60 @@ describe('ActionGroup', () => { expect(secondButton.getAttribute('emphasized') === '').to.be.true; expect(secondButton.emphasized).to.be.true; }); + it('applies `quiet` attribute to slotted children with overlays', async () => { + const el = await fixture( + html` + + + + First + + + + + Second + + + + ` + ); + const firstButton = el.querySelector('#first') as ActionButton; + const secondButton = el.querySelector('#second') as ActionButton; + + await elementUpdated(el); + + expect(firstButton.getAttribute('quiet') === '').to.be.true; + expect(firstButton.quiet).to.be.true; + expect(secondButton.getAttribute('quiet') === '').to.be.true; + expect(secondButton.quiet).to.be.true; + }); + it('applies `emphasized` attribute to slotted children with overlays', async () => { + const el = await fixture( + html` + + + + First + + + + + Second + + + + ` + ); + const firstButton = el.querySelector('#first') as ActionButton; + const secondButton = el.querySelector('#second') as ActionButton; + + await elementUpdated(el); + + expect(firstButton.getAttribute('emphasized') === '').to.be.true; + expect(firstButton.emphasized).to.be.true; + expect(secondButton.getAttribute('emphasized') === '').to.be.true; + expect(secondButton.emphasized).to.be.true; + }); it('loads [selects="single"] action-group accessibly', async () => { const el = await fixture( html`