ant-design/tests/shared/rtlTest.tsx
Eric Wang 7bc3d4f222
chore: Refactor the button test to use typescript (#22953)
* Refactor the button test to use typescript

* update tsconfig.json

* Change file name as a workaround

* update antd-tools
2020-04-13 13:36:23 +08:00

26 lines
755 B
TypeScript

import React from 'react';
import Moment from 'moment';
import MockDate from 'mockdate';
import { mount } from 'enzyme';
import ConfigProvider from '../../components/config-provider';
// eslint-disable-next-line jest/no-export
export default function rtlTest(Component: React.ComponentType, mockDate?: boolean) {
describe(`rtl render`, () => {
it(`component should be rendered correctly in RTL direction`, () => {
if (mockDate) {
MockDate.set(Moment('2000-09-28').toDate());
}
const wrapper = mount(
<ConfigProvider direction="rtl">
<Component />
</ConfigProvider>,
);
expect(wrapper).toMatchRenderedSnapshot();
if (mockDate) {
MockDate.reset();
}
});
});
}