import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
import { vResizable } from '../resizable';
|
|
function mountResizable(el: HTMLElement) {
|
if (typeof vResizable.mounted === 'function') {
|
vResizable.mounted(el, undefined as never, undefined as never, undefined as never);
|
}
|
}
|
|
function appendAntModal(modalClass = '') {
|
const wrap = document.createElement('div');
|
wrap.className = 'ant-modal-wrap';
|
wrap.innerHTML = `
|
<div class="ant-modal ${modalClass}">
|
<div class="ant-modal-content"></div>
|
</div>
|
`;
|
document.body.append(wrap);
|
return wrap;
|
}
|
|
describe('modal resizable directive', () => {
|
beforeEach(() => {
|
document.body.innerHTML = '';
|
});
|
|
afterEach(() => {
|
document.body.innerHTML = '';
|
});
|
|
it('should add resize handle to normal ant modal', () => {
|
const wrap = appendAntModal();
|
|
mountResizable(wrap);
|
|
expect(wrap.querySelector('.modal-resize-handle')).not.toBeNull();
|
});
|
|
it('should not add resize handle to ant confirm modal', () => {
|
const wrap = appendAntModal('ant-modal-confirm');
|
|
mountResizable(wrap);
|
|
expect(wrap.querySelector('.modal-resize-handle')).toBeNull();
|
});
|
});
|