From caedb053723ba21f1685e1e6459a575bdcf8c7a7 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Mon, 1 Jul 2019 17:13:52 +0200 Subject: [PATCH] fix(choice-input): tests for empty modelValue --- packages/choice-input/test/ChoiceInputMixin.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/choice-input/test/ChoiceInputMixin.test.js b/packages/choice-input/test/ChoiceInputMixin.test.js index 3d41e2caf..3aed678bd 100644 --- a/packages/choice-input/test/ChoiceInputMixin.test.js +++ b/packages/choice-input/test/ChoiceInputMixin.test.js @@ -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` { + @user-input-changed="${() => { counter += 1; - }} - > + }}" + > + + `); 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(``); + 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();