2022-05-25 15:28:47 +08:00
|
|
|
import { render } from '../../../tests/utils';
|
2020-11-29 14:15:08 +08:00
|
|
|
import dropIndicatorRender, { offset } from '../utils/dropIndicator';
|
|
|
|
|
|
|
|
describe('dropIndicatorRender', () => {
|
|
|
|
it('work with dropPosition before (1)', () => {
|
|
|
|
const indicator = dropIndicatorRender({
|
|
|
|
dropPosition: 1,
|
|
|
|
dropLevelOffset: 0,
|
|
|
|
indent: 24,
|
|
|
|
prefixCls: 'ant',
|
|
|
|
direction: 'ltr',
|
|
|
|
});
|
2022-05-25 15:28:47 +08:00
|
|
|
const { container } = render(indicator);
|
|
|
|
expect(container.querySelector('div')?.style.bottom).toEqual('-3px');
|
2020-11-29 14:15:08 +08:00
|
|
|
});
|
|
|
|
it('work with dropPosition inner (-0)', () => {
|
|
|
|
const indicator = dropIndicatorRender({
|
|
|
|
dropPosition: 0,
|
|
|
|
dropLevelOffset: 0,
|
|
|
|
indent: 24,
|
|
|
|
prefixCls: 'ant',
|
|
|
|
direction: 'ltr',
|
|
|
|
});
|
2022-05-25 15:28:47 +08:00
|
|
|
const { container } = render(indicator);
|
|
|
|
expect(container.querySelector('div')?.style.bottom).toEqual('-3px');
|
|
|
|
expect(container.querySelector('div')?.style.left).toEqual(`${24 + offset}px`);
|
2020-11-29 14:15:08 +08:00
|
|
|
});
|
|
|
|
it('work with dropPosition after (-1)', () => {
|
|
|
|
const indicator = dropIndicatorRender({
|
|
|
|
dropPosition: -1,
|
|
|
|
dropLevelOffset: 0,
|
|
|
|
indent: 24,
|
|
|
|
prefixCls: 'ant',
|
|
|
|
direction: 'ltr',
|
|
|
|
});
|
2022-05-25 15:28:47 +08:00
|
|
|
const { container } = render(indicator);
|
|
|
|
expect(container.querySelector('div')?.style.top).toEqual('-3px');
|
2020-11-29 14:15:08 +08:00
|
|
|
});
|
|
|
|
it('work with drop level', () => {
|
|
|
|
const indicator = dropIndicatorRender({
|
|
|
|
dropPosition: -1,
|
|
|
|
dropLevelOffset: 2,
|
|
|
|
indent: 24,
|
|
|
|
prefixCls: 'ant',
|
|
|
|
direction: 'ltr',
|
|
|
|
});
|
2022-05-25 15:28:47 +08:00
|
|
|
const { container } = render(indicator);
|
|
|
|
expect(container.querySelector('div')?.style.left).toEqual(`${-2 * 24 + offset}px`);
|
2020-11-29 14:15:08 +08:00
|
|
|
});
|
|
|
|
it('work with drop level (rtl)', () => {
|
|
|
|
const indicator = dropIndicatorRender({
|
|
|
|
dropPosition: -1,
|
|
|
|
dropLevelOffset: 2,
|
|
|
|
indent: 24,
|
|
|
|
prefixCls: 'ant',
|
|
|
|
direction: 'rtl',
|
|
|
|
});
|
2022-05-25 15:28:47 +08:00
|
|
|
const { container } = render(indicator);
|
|
|
|
expect(container.querySelector('div')?.style.right).toEqual(`${-2 * 24 + offset}px`);
|
2020-11-29 14:15:08 +08:00
|
|
|
});
|
|
|
|
});
|