blob: 5f49a6f93725720e2d9e8c93d02dfb420bf17ede (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { shallow } from 'enzyme';
import expect from 'expect';
import React from 'react';
import BackLink from 'src/common/back_link/back_link';
describe('BackLink', () => {
context('as link', () => {
let backLink;
beforeEach(() => {
backLink = shallow(<BackLink text='Back to inbox' href='/' />);
});
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('/');
});
});
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();
});
});
});
|