diff --git a/src/share-button.js b/src/share-button.js index a83c8ad..527b9e7 100644 --- a/src/share-button.js +++ b/src/share-button.js @@ -271,7 +271,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); } @@ -299,9 +299,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')