2019-01-03 16:00:55 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { render, mount } from 'enzyme';
|
|
|
|
import { renderToJson } from 'enzyme-to-json';
|
|
|
|
import { Dialog } from '../src';
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
describe('Dialog', function () {
|
2019-01-03 16:00:55 +03:00
|
|
|
it('renders correctly', () => {
|
|
|
|
const wrapper = render(<Dialog />);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders with props', () => {
|
|
|
|
const wrapper = render(
|
2019-01-10 21:51:14 +03:00
|
|
|
<Dialog title="Dialog Title" open fullWidth>
|
2019-01-03 16:00:55 +03:00
|
|
|
Hello Dialog!
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders modal', () => {
|
|
|
|
const wrapper = render(<Dialog modal />);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle dismiss event', () => {
|
|
|
|
const onDismiss = jest.fn();
|
|
|
|
const wrapper = mount(<Dialog open onDismiss={onDismiss} />);
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
wrapper.find('button').first().simulate('click');
|
2019-01-03 16:00:55 +03:00
|
|
|
expect(onDismiss).toBeCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle submit event', () => {
|
|
|
|
const onSubmit = jest.fn();
|
|
|
|
const wrapper = mount(<Dialog open onSubmit={onSubmit} />);
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
wrapper.find('button').last().simulate('click');
|
2019-01-03 16:00:55 +03:00
|
|
|
expect(onSubmit).toBeCalled();
|
|
|
|
});
|
|
|
|
});
|