You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
4 years ago
|
import React from 'react';
|
||
|
import { shallow } from 'enzyme';
|
||
|
import sinon from 'sinon';
|
||
4 years ago
|
import PageContainerHeader from '../../../components/ui/page-container/page-container-header';
|
||
|
import SendHeader from './send-header.component';
|
||
7 years ago
|
|
||
4 years ago
|
describe('SendHeader Component', () => {
|
||
4 years ago
|
let wrapper;
|
||
7 years ago
|
|
||
5 years ago
|
const propsMethodSpies = {
|
||
|
clearSend: sinon.spy(),
|
||
4 years ago
|
};
|
||
5 years ago
|
const historySpies = {
|
||
|
push: sinon.spy(),
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
beforeAll(() => {
|
||
4 years ago
|
sinon.spy(SendHeader.prototype, 'onClose');
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
wrapper = shallow(
|
||
5 years ago
|
<SendHeader
|
||
|
clearSend={propsMethodSpies.clearSend}
|
||
|
history={historySpies}
|
||
5 years ago
|
mostRecentOverviewPage="mostRecentOverviewPage"
|
||
5 years ago
|
titleKey="mockTitleKey"
|
||
4 years ago
|
/>,
|
||
|
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } },
|
||
4 years ago
|
);
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
afterEach(() => {
|
||
4 years ago
|
propsMethodSpies.clearSend.resetHistory();
|
||
|
historySpies.push.resetHistory();
|
||
|
SendHeader.prototype.onClose.resetHistory();
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
afterAll(() => {
|
||
4 years ago
|
sinon.restore();
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
describe('onClose', () => {
|
||
|
it('should call clearSend', () => {
|
||
|
expect(propsMethodSpies.clearSend.callCount).toStrictEqual(0);
|
||
4 years ago
|
wrapper.instance().onClose();
|
||
4 years ago
|
expect(propsMethodSpies.clearSend.callCount).toStrictEqual(1);
|
||
4 years ago
|
});
|
||
7 years ago
|
|
||
4 years ago
|
it('should call history.push', () => {
|
||
|
expect(historySpies.push.callCount).toStrictEqual(0);
|
||
4 years ago
|
wrapper.instance().onClose();
|
||
4 years ago
|
expect(historySpies.push.callCount).toStrictEqual(1);
|
||
|
expect(historySpies.push.getCall(0).args[0]).toStrictEqual(
|
||
4 years ago
|
'mostRecentOverviewPage',
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('render', () => {
|
||
|
it('should render a PageContainerHeader component', () => {
|
||
|
expect(wrapper.find(PageContainerHeader)).toHaveLength(1);
|
||
4 years ago
|
});
|
||
7 years ago
|
|
||
4 years ago
|
it('should pass the correct props to PageContainerHeader', () => {
|
||
4 years ago
|
const { onClose, title } = wrapper.find(PageContainerHeader).props();
|
||
4 years ago
|
expect(title).toStrictEqual('mockTitleKey');
|
||
|
expect(SendHeader.prototype.onClose.callCount).toStrictEqual(0);
|
||
4 years ago
|
onClose();
|
||
4 years ago
|
expect(SendHeader.prototype.onClose.callCount).toStrictEqual(1);
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|