2018-08-24 13:23:35 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2018-12-18 00:32:51 +03:00
|
|
|
import deleteServerButtonConstruct from '../../src/servers/DeleteServerButton';
|
2018-08-24 13:23:35 +03:00
|
|
|
import DeleteServerModal from '../../src/servers/DeleteServerModal';
|
|
|
|
|
|
|
|
describe('<DeleteServerButton />', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2018-08-26 00:39:27 +03:00
|
|
|
beforeEach(() => {
|
2018-12-18 00:32:51 +03:00
|
|
|
const DeleteServerButton = deleteServerButtonConstruct(DeleteServerModal);
|
|
|
|
|
2018-08-26 00:39:27 +03:00
|
|
|
wrapper = shallow(<DeleteServerButton server={{}} className="button" />);
|
|
|
|
});
|
2018-08-24 13:23:35 +03:00
|
|
|
afterEach(() => wrapper.unmount());
|
|
|
|
|
|
|
|
it('renders a button and a modal', () => {
|
|
|
|
expect(wrapper.find('.button')).toHaveLength(1);
|
|
|
|
expect(wrapper.find(DeleteServerModal)).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('displays modal when button is clicked', () => {
|
|
|
|
const btn = wrapper.find('.button');
|
|
|
|
|
2020-03-05 13:58:35 +03:00
|
|
|
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(false);
|
2018-08-24 13:23:35 +03:00
|
|
|
btn.simulate('click');
|
2020-03-05 13:58:35 +03:00
|
|
|
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(true);
|
2018-08-24 13:23:35 +03:00
|
|
|
});
|
|
|
|
});
|