From dad23e09bac61a377c5ee8c055efccc9cb5510ff Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 11 Jun 2019 10:54:52 -0400 Subject: [PATCH 1/2] Respect "hidden" attributes when testing Wrapper.isVisible() Elements that are hidden via the HTML `hidden` attribute were erroneously being reported as being visible by the `isVisible()` method, even though they were not actually visible in the DOM. --- packages/test-utils/src/wrapper.js | 8 +++++--- test/specs/wrapper/isVisible.spec.js | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 60346ce9a..6610831f5 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -270,9 +270,11 @@ export default class Wrapper implements BaseWrapper { let element = this.element while (element) { if ( - element.style && - (element.style.visibility === 'hidden' || - element.style.display === 'none') + element.hidden || + (element.style && + (element.style.visibility === 'hidden' || + element.style.display === 'none') + ) ) { return false } diff --git a/test/specs/wrapper/isVisible.spec.js b/test/specs/wrapper/isVisible.spec.js index 359560fc7..a269f34e7 100644 --- a/test/specs/wrapper/isVisible.spec.js +++ b/test/specs/wrapper/isVisible.spec.js @@ -32,6 +32,15 @@ describeWithShallowAndMount('isVisible', mountingMethod => { expect(element.isVisible()).to.equal(false) }) + it('returns false if element has hidden attribute', () => { + const compiled = compileToFunctions( + '
' + ) + const wrapper = mountingMethod(compiled) + const element = wrapper.find('.visible') + expect(element.isVisible()).to.equal(false) + }) + it('returns true if element has v-show true', async () => { const wrapper = mountingMethod(ComponentWithVShow) wrapper.vm.$set(wrapper.vm, 'ready', true) From 2833055525219b8fbfbf75d5ed1e1bd414db64a4 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Tue, 11 Jun 2019 11:03:11 -0400 Subject: [PATCH 2/2] Update coding standards per Prettier --- packages/test-utils/src/wrapper.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 6610831f5..956227a8b 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -273,8 +273,7 @@ export default class Wrapper implements BaseWrapper { element.hidden || (element.style && (element.style.visibility === 'hidden' || - element.style.display === 'none') - ) + element.style.display === 'none')) ) { return false }