ant-design/components/divider/__tests__/index.test.tsx
Pinaki Raj 218e1cea3d
feat: adding variant props to divider (#49654)
The divider border style can be either solid, dashed or
dotted based on the variant props. The default value is
solid.

Signed-off-by: Pinaki Raj <pinakiraj15@gmail.com>
2024-07-01 23:17:48 +08:00

52 lines
1.4 KiB
TypeScript

import * as React from 'react';
import Divider from '..';
import mountTest from '../../../tests/shared/mountTest';
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>);
expect(container.querySelector<HTMLSpanElement>('.ant-divider-inner-text')).toBeFalsy();
errSpy.mockRestore();
});
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',
});
});
it('support string variant', () => {
const { container } = render(
<Divider variant="dotted">
test dotted
</Divider>,
);
expect(container?.querySelector<HTMLSpanElement>('.ant-divider-dotted')).toHaveStyle({
borderStyle: 'dotted',
});
});
});