diff options
Diffstat (limited to 'web-ui/src/common/back_link/back_link.spec.js')
-rw-r--r-- | web-ui/src/common/back_link/back_link.spec.js | 37 |
1 files changed, 29 insertions, 8 deletions
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(<BackLink text='Back to inbox' href='/' />); - }); + beforeEach(() => { + backLink = shallow(<BackLink text='Back to inbox' href='/' />); + }); + + 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(<BackLink text='Back to inbox' onClick={mockClick} />); + }); + + 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(); + }); }); }); |