chore: add more listbox regression tests
This commit is contained in:
parent
8f4faee0c6
commit
8a3a3bbaee
3 changed files with 35 additions and 10 deletions
|
|
@ -545,7 +545,6 @@ describe('lion-combobox', () => {
|
||||||
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
<lion-option .choiceValue="${'10'}" checked>Item 1</lion-option>
|
||||||
</lion-combobox>
|
</lion-combobox>
|
||||||
`));
|
`));
|
||||||
// @ts-expect-error sinon not typed correctly?
|
|
||||||
const spy = sinon.spy(el._selectionDisplayNode, 'onComboboxElementUpdated');
|
const spy = sinon.spy(el._selectionDisplayNode, 'onComboboxElementUpdated');
|
||||||
el.requestUpdate('modelValue');
|
el.requestUpdate('modelValue');
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,14 @@ export function runListboxMixinSuite(customConfig = {}) {
|
||||||
</${tag}>
|
</${tag}>
|
||||||
`);
|
`);
|
||||||
expect(el.checkedIndex).to.equal(2);
|
expect(el.checkedIndex).to.equal(2);
|
||||||
const spy = sinon.spy(el, 'requestUpdate');
|
const requestSpy = sinon.spy(el, 'requestUpdate');
|
||||||
|
const updatedSpy = sinon.spy(el, 'updated');
|
||||||
el.setCheckedIndex(1);
|
el.setCheckedIndex(1);
|
||||||
expect(spy).to.have.been.calledWith('modelValue', 'other');
|
await el.updateComplete;
|
||||||
|
expect(requestSpy).to.have.been.calledWith('modelValue', 'other');
|
||||||
|
expect(updatedSpy).to.have.been.calledWith(
|
||||||
|
sinon.match.map.contains(new Map([['modelValue', 'other']])),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requests update for modelValue after click', async () => {
|
it('requests update for modelValue after click', async () => {
|
||||||
|
|
@ -133,9 +138,14 @@ export function runListboxMixinSuite(customConfig = {}) {
|
||||||
</${tag}>
|
</${tag}>
|
||||||
`);
|
`);
|
||||||
expect(el.checkedIndex).to.equal(2);
|
expect(el.checkedIndex).to.equal(2);
|
||||||
const spy = sinon.spy(el, 'requestUpdate');
|
const requestSpy = sinon.spy(el, 'requestUpdate');
|
||||||
|
const updatedSpy = sinon.spy(el, 'updated');
|
||||||
el.formElements[0].click();
|
el.formElements[0].click();
|
||||||
expect(spy).to.have.been.calledWith('modelValue', 'other');
|
await el.updateComplete;
|
||||||
|
expect(requestSpy).to.have.been.calledWith('modelValue', 'other');
|
||||||
|
expect(updatedSpy).to.have.been.calledWith(
|
||||||
|
sinon.match.map.contains(new Map([['modelValue', 'other']])),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requests update for modelValue when checkedIndex changes for multiple choice', async () => {
|
it('requests update for modelValue when checkedIndex changes for multiple choice', async () => {
|
||||||
|
|
@ -147,9 +157,17 @@ export function runListboxMixinSuite(customConfig = {}) {
|
||||||
</${tag}>
|
</${tag}>
|
||||||
`);
|
`);
|
||||||
expect(el.checkedIndex).to.eql([2]);
|
expect(el.checkedIndex).to.eql([2]);
|
||||||
const spy = sinon.spy(el, 'requestUpdate');
|
const requestSpy = sinon.spy(el, 'requestUpdate');
|
||||||
|
const updatedSpy = sinon.spy(el, 'updated');
|
||||||
el.setCheckedIndex(1);
|
el.setCheckedIndex(1);
|
||||||
expect(spy).to.have.been.calledWith('modelValue', sinon.match.array.deepEquals(['other']));
|
await el.updateComplete;
|
||||||
|
expect(requestSpy).to.have.been.calledWith(
|
||||||
|
'modelValue',
|
||||||
|
sinon.match.array.deepEquals(['other']),
|
||||||
|
);
|
||||||
|
expect(updatedSpy).to.have.been.calledOnce;
|
||||||
|
// reference values vs real values suck :( had to do it like this, sinon matchers did not match because 'other' is inside an array so it's not a "real" match
|
||||||
|
expect([...updatedSpy.args[0][0].entries()]).to.deep.include(['modelValue', ['other']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requests update for modelValue after click for multiple choice', async () => {
|
it('requests update for modelValue after click for multiple choice', async () => {
|
||||||
|
|
@ -161,9 +179,17 @@ export function runListboxMixinSuite(customConfig = {}) {
|
||||||
</${tag}>
|
</${tag}>
|
||||||
`);
|
`);
|
||||||
expect(el.checkedIndex).to.eql([2]);
|
expect(el.checkedIndex).to.eql([2]);
|
||||||
const spy = sinon.spy(el, 'requestUpdate');
|
const requestSpy = sinon.spy(el, 'requestUpdate');
|
||||||
|
const updatedSpy = sinon.spy(el, 'updated');
|
||||||
el.formElements[0].click();
|
el.formElements[0].click();
|
||||||
expect(spy).to.have.been.calledWith('modelValue', sinon.match.array.deepEquals(['other']));
|
await el.updateComplete;
|
||||||
|
expect(requestSpy).to.have.been.calledWith(
|
||||||
|
'modelValue',
|
||||||
|
sinon.match.array.deepEquals(['other']),
|
||||||
|
);
|
||||||
|
expect(updatedSpy).to.have.been.calledOnce;
|
||||||
|
// reference values vs real values suck :( had to do it like this, sinon matchers did not match because 'other' is inside an array so it's not a "real" match
|
||||||
|
expect([...updatedSpy.args[0][0].entries()]).to.deep.include(['modelValue', ['other']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`has a fieldName based on the label`, async () => {
|
it(`has a fieldName based on the label`, async () => {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ export declare function ListboxImplementation<T extends Constructor<LitElement>>
|
||||||
superclass: T,
|
superclass: T,
|
||||||
): T &
|
): T &
|
||||||
Constructor<ListboxHost> &
|
Constructor<ListboxHost> &
|
||||||
ListboxHost &
|
typeof ListboxHost &
|
||||||
Constructor<ChoiceGroupHost> &
|
Constructor<ChoiceGroupHost> &
|
||||||
typeof ChoiceGroupHost &
|
typeof ChoiceGroupHost &
|
||||||
Constructor<SlotHost> &
|
Constructor<SlotHost> &
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue