Skip to content

Commit caedb05

Browse files
committed
fix(choice-input): tests for empty modelValue
1 parent 0b1cb9f commit caedb05

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/choice-input/test/ChoiceInputMixin.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ describe('ChoiceInputMixin', () => {
1212
if (super.connectedCallback) super.connectedCallback();
1313
this.type = 'checkbox'; // could also be 'radio', should be tested in integration test
1414
}
15+
16+
_syncValueUpwards() {} // We need to disable the method for the test to pass
1517
}
1618
customElements.define('choice-input', ChoiceInput);
1719
});
@@ -68,16 +70,19 @@ describe('ChoiceInputMixin', () => {
6870
let counter = 0;
6971
const el = await fixture(html`
7072
<choice-input
71-
@user-input-changed=${() => {
73+
@user-input-changed="${() => {
7274
counter += 1;
73-
}}
74-
></choice-input>
75+
}}"
76+
>
77+
<input slot="input" />
78+
</choice-input>
7579
`);
7680
expect(counter).to.equal(0);
7781
// Here we try to mimic user interaction by firing browser events
7882
const nativeInput = el.inputElement;
7983
nativeInput.dispatchEvent(new CustomEvent('input', { bubbles: true })); // fired by (at least) Chrome
8084
expect(counter).to.equal(0);
85+
el._syncValueUpwards = () => {}; // We need to disable the method for the test to pass
8186
nativeInput.dispatchEvent(new CustomEvent('change', { bubbles: true }));
8287
expect(counter).to.equal(1);
8388
});
@@ -117,6 +122,7 @@ describe('ChoiceInputMixin', () => {
117122

118123
it('can be checked and unchecked via user interaction', async () => {
119124
const el = await fixture(`<choice-input></choice-input>`);
125+
el._syncValueUpwards = () => {}; // We need to disable the method for the test to pass
120126
el.inputElement.click();
121127
expect(el.checked).to.be.true;
122128
el.inputElement.click();

0 commit comments

Comments
 (0)