ant-design/components/divider/__tests__/index.test.tsx

41 lines
1.1 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
import Divider from '..';
import mountTest from '../../../tests/shared/mountTest';
2023-06-03 18:16:28 +08:00
import { render } from '../../../tests/utils';
describe('Divider', () => {
mountTest(Divider);
it('not show children when vertical', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(<Divider type="vertical">Bamboo</Divider>);
2023-06-03 18:16:28 +08:00
expect(container.querySelector<HTMLSpanElement>('.ant-divider-inner-text')).toBeFalsy();
errSpy.mockRestore();
});
2023-06-03 18:16:28 +08:00
it('support string orientationMargin', () => {
const { container } = render(
<Divider orientation="right" orientationMargin="10">
test test test
</Divider>,
);
expect(container?.querySelector<HTMLSpanElement>('.ant-divider-inner-text')).toHaveStyle({
marginRight: 10,
});
});
it('support bool dashed', () => {
const { container } = render(
<Divider dashed>
test test test
</Divider>,
);
expect(container?.querySelector<HTMLSpanElement>('.ant-divider-dashed')).toHaveStyle({
borderStyle: 'dashed',
});
});
});