From 4c9fe3cce2cea8270959060d3b1e1e017a82f41f Mon Sep 17 00:00:00 2001 From: 38elements <38elements@users.noreply.github.com> Date: Fri, 29 Jun 2018 16:28:57 +0900 Subject: [PATCH] fix: handle textarea correctly in setValue() and setChecked() (#771) --- packages/test-utils/src/wrapper.js | 4 ++-- test/specs/wrapper/setChecked.spec.js | 1 + test/specs/wrapper/setSelected.spec.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 77ed8c2c7..53d822d69 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -748,7 +748,7 @@ export default class Wrapper implements BaseWrapper { this.trigger('change') } } - } else if (tagName === 'INPUT' || tagName === 'textarea') { + } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') { throwError( `wrapper.setChecked() cannot be called on "text" ` + `inputs. Use wrapper.setValue() instead` @@ -795,7 +795,7 @@ export default class Wrapper implements BaseWrapper { `type="radio" /> element. Use wrapper.setChecked() ` + `instead` ) - } else if (tagName === 'INPUT' || tagName === 'textarea') { + } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') { throwError( `wrapper.setSelected() cannot be called on "text" ` + `inputs. Use wrapper.setValue() instead` diff --git a/test/specs/wrapper/setChecked.spec.js b/test/specs/wrapper/setChecked.spec.js index 805b504b8..4c6accb09 100644 --- a/test/specs/wrapper/setChecked.spec.js +++ b/test/specs/wrapper/setChecked.spec.js @@ -93,6 +93,7 @@ describeWithShallowAndMount('setChecked', mountingMethod => { const message = 'wrapper.setChecked() cannot be called on "text" inputs. Use wrapper.setValue() instead' shouldThrowErrorOnElement('input[type="text"]', message) + shouldThrowErrorOnElement('textarea', message) }) it('throws error if element is not valid', () => { diff --git a/test/specs/wrapper/setSelected.spec.js b/test/specs/wrapper/setSelected.spec.js index c374af856..5b6375d5f 100644 --- a/test/specs/wrapper/setSelected.spec.js +++ b/test/specs/wrapper/setSelected.spec.js @@ -49,6 +49,7 @@ describeWithShallowAndMount('setSelected', mountingMethod => { const message = 'wrapper.setSelected() cannot be called on "text" inputs. Use wrapper.setValue() instead' shouldThrowErrorOnElement('input[type="text"]', message) + shouldThrowErrorOnElement('textarea', message) }) it('throws error if element is not valid', () => {