From ab12f2768baaeefe6022501675a4d85b026e75a6 Mon Sep 17 00:00:00 2001 From: palash2601 Date: Thu, 16 Apr 2020 13:46:52 +0200 Subject: [PATCH] chore(select-rich): added tests --- .../test/lion-select-invoker.test.js | 16 +++++++++++++ .../select-rich/test/lion-select-rich.test.js | 23 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/packages/select-rich/test/lion-select-invoker.test.js b/packages/select-rich/test/lion-select-invoker.test.js index 526470252..4f1df75f4 100644 --- a/packages/select-rich/test/lion-select-invoker.test.js +++ b/packages/select-rich/test/lion-select-invoker.test.js @@ -48,6 +48,22 @@ describe('lion-select-invoker', () => { expect(el.getAttribute('tabindex')).to.equal('0'); }); + it('should not render after slot when singleOption is true', async () => { + const el = await fixture(html` + + `); + + expect(el.shadowRoot.querySelector('slot[name="after"]')).to.not.exist; + }); + + it('should render after slot when singleOption is not true', async () => { + const el = await fixture(html` + + `); + + expect(el.shadowRoot.querySelector('slot[name="after"]')).to.exist; + }); + describe('Subclassers', () => { it('supports a custom _contentTemplate', async () => { const myTag = defineCE( diff --git a/packages/select-rich/test/lion-select-rich.test.js b/packages/select-rich/test/lion-select-rich.test.js index dd04cca8e..b6e14a2b9 100644 --- a/packages/select-rich/test/lion-select-rich.test.js +++ b/packages/select-rich/test/lion-select-rich.test.js @@ -429,6 +429,29 @@ describe('lion-select-rich', () => { expect(el._overlayCtrl.inheritsReferenceWidth).to.equal('full'); }); + + it('should set singleOption to true when options change dynamically to 1 option', async () => { + const elSingleoption = await fixture(html` + + + Item 1 + Item 2 + + + `); + + elSingleoption._invokerNode.click(); + await elSingleoption.updateComplete; + expect(elSingleoption.singleOption).to.be.undefined; + + const optionELm = elSingleoption.querySelectorAll('lion-option')[0]; + optionELm.parentNode.removeChild(optionELm); + elSingleoption.requestUpdate(); + + elSingleoption._invokerNode.click(); + await elSingleoption.updateComplete; + expect(elSingleoption.singleOption).to.be.true; + }); }); describe('interaction-mode', () => {