summaryrefslogtreecommitdiff
path: root/web-ui/src/common/back_link/back_link.spec.js
diff options
context:
space:
mode:
authorAnike Arni <aarni@thoughtworks.com>2017-03-29 17:10:19 -0300
committerAnike Arni <aarni@thoughtworks.com>2017-03-30 15:10:57 -0300
commit9a2a9cf5f4d13e2bc9bb0bd997ecd22ec5241b4b (patch)
tree70e5175f723e9940eeb83373c1a41a9fc01e4fd9 /web-ui/src/common/back_link/back_link.spec.js
parent26cb72e514a51d571e13dfd74e99f6b2499efe22 (diff)
[#932] Makes back link a button
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.js37
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();
+ });
});
});