2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { shallow } from 'enzyme';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-03-16 22:00:08 +01:00
|
|
|
import InfoBox from './info-box.component';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('InfoBox', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
let wrapper;
|
2020-01-30 20:34:45 +01:00
|
|
|
|
|
|
|
const props = {
|
|
|
|
title: 'Title',
|
|
|
|
description: 'Description',
|
|
|
|
onClose: sinon.spy(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
beforeEach(() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
wrapper = shallow(<InfoBox {...props} />);
|
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('renders title from props', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const title = wrapper.find('.info-box__title');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(title.text()).toStrictEqual(props.title);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('renders description from props', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const description = wrapper.find('.info-box__description');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(description.text()).toStrictEqual(props.description);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
it('closes info box', () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const close = wrapper.find('.info-box__close');
|
|
|
|
close.simulate('click');
|
2021-04-15 20:01:46 +02:00
|
|
|
expect(props.onClose.calledOnce).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|