import { configure, mount, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import * as React from 'react';
import renderer from 'react-test-renderer';
import MDDatePicker from '../index';
configure({ adapter: new Adapter() });
it('renders correctly with defaults', () => {
const component = renderer.create().toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with Date mode', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with Time mode', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with DateTime mode', () => {
const component = renderer
.create(
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('renders correctly with cuntom mode', () => {
const component = renderer
.create(
{
// @ts-ignore
const args = Array.prototype.slice.call(arguments);
const typeFormat = args[0]; // 类型
// const column0Value = args[1] // 第1列选中值
// const column1Value = args[2] // 第2列选中值
const column2Value = args[3]; // 第3列选中值
if (typeFormat === 'dd') {
return `*${column2Value}日`;
}
}}
customTypes={['yyyy', 'MM', 'dd', 'hh', 'mm']}
defaultDate={new Date('2019/9/9')}
isView={true}
/>
)
.toJSON();
expect(component).toMatchSnapshot();
});
it('test public method', () => {
const component = mount(
{
// @ts-ignore
const args = Array.prototype.slice.call(arguments);
const typeFormat = args[0]; // 类型
// const column0Value = args[1] // 第1列选中值
// const column1Value = args[2] // 第2列选中值
const column2Value = args[3]; // 第3列选中值
if (typeFormat === 'dd') {
return `*${column2Value}日`;
}
}}
customTypes={['yyyy', 'MM', 'dd', 'hh', 'mm']}
defaultDate={new Date()}
isView={true}
/>
);
const instance: any = component.instance();
expect(instance.getFormatDate('yyyy-MM-dd hh:mm')).toEqual('1');
// expect(instance.getColumnValue(1)).toEqual('1');
// expect(instance.getColumnValues()).toEqual('1');
// expect(instance.getColumnIndex(1)).toEqual('1');
// expect(instance.getColumnIndexs()).toEqual('1');
});