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.
36 lines
872 B
36 lines
872 B
4 years ago
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
|
import { shallow } from 'enzyme';
|
||
5 years ago
|
|
||
4 years ago
|
import InfoBox from './info-box.component';
|
||
5 years ago
|
|
||
4 years ago
|
describe('InfoBox', () => {
|
||
4 years ago
|
let wrapper;
|
||
5 years ago
|
|
||
|
const props = {
|
||
|
title: 'Title',
|
||
|
description: 'Description',
|
||
|
onClose: sinon.spy(),
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
4 years ago
|
wrapper = shallow(<InfoBox {...props} />);
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('renders title from props', () => {
|
||
4 years ago
|
const title = wrapper.find('.info-box__title');
|
||
4 years ago
|
expect(title.text()).toStrictEqual(props.title);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('renders description from props', () => {
|
||
4 years ago
|
const description = wrapper.find('.info-box__description');
|
||
4 years ago
|
expect(description.text()).toStrictEqual(props.description);
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('closes info box', () => {
|
||
4 years ago
|
const close = wrapper.find('.info-box__close');
|
||
|
close.simulate('click');
|
||
4 years ago
|
expect(props.onClose.calledOnce).toStrictEqual(true);
|
||
4 years ago
|
});
|
||
|
});
|