From 0a549aec931211779814abdd63832803e4f9c5a1 Mon Sep 17 00:00:00 2001 From: Sebastian Herber Date: Fri, 4 Dec 2015 16:39:44 +0100 Subject: [PATCH 1/2] Fixes the close() method --- src/share-button.js | 7 ++++--- tests/features/basic.feature | 5 +++++ tests/fixtures/basic.html | 12 ++++++++++++ tests/steps/basic.coffee | 9 +++++++++ tests/widgets/shareButton.coffee | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/share-button.js b/src/share-button.js index 0566d45..8564192 100644 --- a/src/share-button.js +++ b/src/share-button.js @@ -272,7 +272,7 @@ class ShareButton extends ShareUtils { */ _eventToggle(button, networks) { if (this._hasClass(networks, 'active')) - this._eventClose(networks); + this._eventClose(button, networks); else this._eventOpen(button, networks); } @@ -300,9 +300,10 @@ class ShareButton extends ShareUtils { * @private * * @param {DOMNode} button + * @param {DOMNode} networks */ - _eventClose(button) { - this._removeClass(button, 'active'); + _eventClose(button, networks) { + this._removeClass(networks, 'active'); } /** diff --git a/tests/features/basic.feature b/tests/features/basic.feature index 44569e8..a10c606 100644 --- a/tests/features/basic.feature +++ b/tests/features/basic.feature @@ -7,3 +7,8 @@ Feature: Basic Button Scenario: All social networks should be displayed When I click the Share Button Then I should see all Social Networks + + @basic + Scenario: All social networks should be hidden + When I close the Share Button manually by calling the close method + Then I should no longer see any Social Network diff --git a/tests/fixtures/basic.html b/tests/fixtures/basic.html index eb1aaa2..57fca0a 100644 --- a/tests/fixtures/basic.html +++ b/tests/fixtures/basic.html @@ -17,6 +17,14 @@ right: 0; z-index: 100; } + #close { + float: right; + border: 2px solid #f00; + padding: 10px; + text-transform: uppercase; + background-color: #fff; + text-align: center; + } @@ -24,6 +32,7 @@ + diff --git a/tests/steps/basic.coffee b/tests/steps/basic.coffee index 3f361c5..9144daa 100644 --- a/tests/steps/basic.coffee +++ b/tests/steps/basic.coffee @@ -22,3 +22,12 @@ module.exports = -> .each (item, i) -> unless (item.hasClass('whatsapp').then (tf) -> tf) item.isVisible().should.eventually.eql(true) + + @When /^I close the Share Button manually by calling the close method$/, -> + new @Widgets.Body().triggerCloseButton() + + @Then /^I should no longer see any Social Network$/, -> + new @Widgets + .ShareButtonNetworks() + .each (item, i) -> + item.isVisible().should.eventually.eql(false) diff --git a/tests/widgets/shareButton.coffee b/tests/widgets/shareButton.coffee index 690d4d0..c9f2a9a 100644 --- a/tests/widgets/shareButton.coffee +++ b/tests/widgets/shareButton.coffee @@ -27,3 +27,9 @@ module.exports = -> @Widgets.ShareButtonNetworks = @Widget.List.extend root: 'share-button ul' itemSelector: 'li' + + @Widgets.Body = @Widget.extend + root: 'body' + + triggerCloseButton: -> + return this.click('#close') From 1e358fc961cbce077a41fa0dedc4a5e12d31d1ab Mon Sep 17 00:00:00 2001 From: Sebastian Herber Date: Sat, 5 Dec 2015 23:08:08 +0100 Subject: [PATCH 2/2] Updates test for close() fix So the test eventually .. i mean .. actually .. works. ;-) Related: #253 --- tests/steps/basic.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/steps/basic.coffee b/tests/steps/basic.coffee index 9144daa..03acb4e 100644 --- a/tests/steps/basic.coffee +++ b/tests/steps/basic.coffee @@ -24,10 +24,11 @@ module.exports = -> item.isVisible().should.eventually.eql(true) @When /^I close the Share Button manually by calling the close method$/, -> + new @Widgets.ShareButton().click() new @Widgets.Body().triggerCloseButton() @Then /^I should no longer see any Social Network$/, -> new @Widgets - .ShareButtonNetworks() - .each (item, i) -> - item.isVisible().should.eventually.eql(false) + .ShareButtonSocial() + .hasClass('active') + .should.eventually.be.false