chore(select-rich): added tests

This commit is contained in:
palash2601 2020-04-16 13:46:52 +02:00
parent 9467a52e45
commit ab12f2768b
2 changed files with 39 additions and 0 deletions

View file

@ -48,6 +48,22 @@ describe('lion-select-invoker', () => {
expect(el.getAttribute('tabindex')).to.equal('0'); expect(el.getAttribute('tabindex')).to.equal('0');
}); });
it('should not render after slot when singleOption is true', async () => {
const el = await fixture(html`
<lion-select-invoker .singleOption="${true}"></lion-select-invoker>
`);
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`
<lion-select-invoker></lion-select-invoker>
`);
expect(el.shadowRoot.querySelector('slot[name="after"]')).to.exist;
});
describe('Subclassers', () => { describe('Subclassers', () => {
it('supports a custom _contentTemplate', async () => { it('supports a custom _contentTemplate', async () => {
const myTag = defineCE( const myTag = defineCE(

View file

@ -429,6 +429,29 @@ describe('lion-select-rich', () => {
expect(el._overlayCtrl.inheritsReferenceWidth).to.equal('full'); 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`
<lion-select-rich>
<lion-options slot="input">
<lion-option .choiceValue=${10}>Item 1</lion-option>
<lion-option .choiceValue=${20}>Item 2</lion-option>
</lion-options>
</lion-select-rich>
`);
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', () => { describe('interaction-mode', () => {