From 9a2a9cf5f4d13e2bc9bb0bd997ecd22ec5241b4b Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Wed, 29 Mar 2017 17:10:19 -0300 Subject: [#932] Makes back link a button --- web-ui/src/common/back_link/back_link.spec.js | 37 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'web-ui/src/common/back_link/back_link.spec.js') diff --git a/web-ui/src/common/back_link/back_link.spec.js b/web-ui/src/common/back_link/back_link.spec.js index ee659267..5f49a6f9 100644 --- a/web-ui/src/common/back_link/back_link.spec.js +++ b/web-ui/src/common/back_link/back_link.spec.js @@ -4,17 +4,38 @@ import React from 'react'; import BackLink from 'src/common/back_link/back_link'; describe('BackLink', () => { - let backLink; + context('as link', () => { + let backLink; - beforeEach(() => { - backLink = shallow(); - }); + beforeEach(() => { + backLink = shallow(); + }); + + it('renders link with text', () => { + expect(backLink.find('a').text()).toEqual('Back to inbox'); + }); - it('renders link with text', () => { - expect(backLink.find('a').text()).toEqual('Back to inbox'); + it('adds link action', () => { + expect(backLink.find('a').props().href).toEqual('/'); + }); }); - it('adds link action', () => { - expect(backLink.find('a').props().href).toEqual('/'); + context('as button', () => { + let backLink; + let mockClick; + + beforeEach(() => { + mockClick = expect.createSpy(); + backLink = shallow(); + }); + + it('renders button with text', () => { + expect(backLink.find('button').text()).toEqual('Back to inbox'); + }); + + it('adds button click event', () => { + backLink.find('button').simulate('click'); + expect(mockClick).toHaveBeenCalled(); + }); }); }); -- cgit v1.2.3