From 84e268be2df1d5a11ac2eff453aa292c12323083 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 6 May 2017 17:32:27 -0700 Subject: [PATCH] add star logic to tests --- .../components/common/InfoAndHelp.spec.js | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/frontend/test/components/common/InfoAndHelp.spec.js b/frontend/test/components/common/InfoAndHelp.spec.js index adc05190..cef37273 100644 --- a/frontend/test/components/common/InfoAndHelp.spec.js +++ b/frontend/test/components/common/InfoAndHelp.spec.js @@ -55,6 +55,34 @@ function assertContent({ currentUser, map }) { }) } +function assertStarLogic({ mapIsStarred }) { + const onMapStar = sinon.spy() + const onMapUnstar = sinon.spy() + const wrapper = shallow( + ) + const starWrapper = wrapper.find('.starMap') + starWrapper.simulate('click') + if (mapIsStarred) { + it('has unstar content', () => { + expect(starWrapper.hasClass('starred')).to.equal(true) + expect(starWrapper.find('.tooltipsAbove').text()).to.equal('Unstar') + expect(onMapStar).to.have.property('callCount', 0) + expect(onMapUnstar).to.have.property('callCount', 1) + }) + } else { + it('has star content', () => { + expect(starWrapper.hasClass('starred')).to.equal(false) + expect(starWrapper.find('.tooltipsAbove').text()).to.equal('Star') + expect(onMapStar).to.have.property('callCount', 1) + expect(onMapUnstar).to.have.property('callCount', 0) + }) + } +} + describe('InfoAndHelp', function() { describe('no currentUser, map is present', function() { assertContent({ currentUser: null, map: {} }) @@ -65,5 +93,6 @@ describe('InfoAndHelp', function() { describe('no currentUser, no map', function() { assertContent({ currentUser: null, map: null }) }) + assertStarLogic({ mapIsStarred: true }) + assertStarLogic({ mapIsStarred: false }) }) -