fix(choice-input): tests for empty modelValue
This commit is contained in:
parent
0b1cb9fe34
commit
caedb05372
1 changed files with 9 additions and 3 deletions
|
|
@ -12,6 +12,8 @@ describe('ChoiceInputMixin', () => {
|
|||
if (super.connectedCallback) super.connectedCallback();
|
||||
this.type = 'checkbox'; // could also be 'radio', should be tested in integration test
|
||||
}
|
||||
|
||||
_syncValueUpwards() {} // We need to disable the method for the test to pass
|
||||
}
|
||||
customElements.define('choice-input', ChoiceInput);
|
||||
});
|
||||
|
|
@ -68,16 +70,19 @@ describe('ChoiceInputMixin', () => {
|
|||
let counter = 0;
|
||||
const el = await fixture(html`
|
||||
<choice-input
|
||||
@user-input-changed=${() => {
|
||||
@user-input-changed="${() => {
|
||||
counter += 1;
|
||||
}}
|
||||
></choice-input>
|
||||
}}"
|
||||
>
|
||||
<input slot="input" />
|
||||
</choice-input>
|
||||
`);
|
||||
expect(counter).to.equal(0);
|
||||
// Here we try to mimic user interaction by firing browser events
|
||||
const nativeInput = el.inputElement;
|
||||
nativeInput.dispatchEvent(new CustomEvent('input', { bubbles: true })); // fired by (at least) Chrome
|
||||
expect(counter).to.equal(0);
|
||||
el._syncValueUpwards = () => {}; // We need to disable the method for the test to pass
|
||||
nativeInput.dispatchEvent(new CustomEvent('change', { bubbles: true }));
|
||||
expect(counter).to.equal(1);
|
||||
});
|
||||
|
|
@ -117,6 +122,7 @@ describe('ChoiceInputMixin', () => {
|
|||
|
||||
it('can be checked and unchecked via user interaction', async () => {
|
||||
const el = await fixture(`<choice-input></choice-input>`);
|
||||
el._syncValueUpwards = () => {}; // We need to disable the method for the test to pass
|
||||
el.inputElement.click();
|
||||
expect(el.checked).to.be.true;
|
||||
el.inputElement.click();
|
||||
|
|
|
|||
Loading…
Reference in a new issue