2020-08-29 09:19:15 +02:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
|
|
|
import { Mock } from 'ts-mockery';
|
2018-12-17 22:32:51 +01:00
|
|
|
import deleteServerButtonConstruct from '../../src/servers/DeleteServerButton';
|
2020-08-29 09:19:15 +02:00
|
|
|
import { ServerWithId } from '../../src/servers/data';
|
2018-08-24 12:23:35 +02:00
|
|
|
|
|
|
|
describe('<DeleteServerButton />', () => {
|
2020-08-29 09:19:15 +02:00
|
|
|
let wrapper: ShallowWrapper;
|
|
|
|
const DeleteServerModal = () => null;
|
2018-08-24 12:23:35 +02:00
|
|
|
|
2018-08-25 23:39:27 +02:00
|
|
|
beforeEach(() => {
|
2018-12-17 22:32:51 +01:00
|
|
|
const DeleteServerButton = deleteServerButtonConstruct(DeleteServerModal);
|
|
|
|
|
2020-08-29 09:19:15 +02:00
|
|
|
wrapper = shallow(<DeleteServerButton server={Mock.all<ServerWithId>()} className="button" />);
|
2018-08-25 23:39:27 +02:00
|
|
|
});
|
2018-08-24 12:23:35 +02: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 11:58:35 +01:00
|
|
|
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(false);
|
2018-08-24 12:23:35 +02:00
|
|
|
btn.simulate('click');
|
2020-03-05 11:58:35 +01:00
|
|
|
expect(wrapper.find(DeleteServerModal).prop('isOpen')).toEqual(true);
|
2018-08-24 12:23:35 +02:00
|
|
|
});
|
|
|
|
});
|