mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-07-11 16:41:05 +08:00
Compare commits
No commits in common. "2cc4ca63b5954febc9fa0d14366cd1011ff50ea0" and "2f9f961bd85c495edb6c6449d8ed5307c2c6de1a" have entirely different histories.
2cc4ca63b5
...
2f9f961bd8
@ -171,9 +171,8 @@ test('should free direction move when axis is "xy" ', async () => {
|
||||
});
|
||||
|
||||
test('should free direction move and magnetic to x axios when magnetic is "x" ', async () => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
|
||||
|
||||
const root = document.createElement('div');
|
||||
mount(FloatingBubble, {
|
||||
props: {
|
||||
@ -188,7 +187,8 @@ test('should free direction move and magnetic to x axios when magnetic is "x" '
|
||||
)!;
|
||||
|
||||
await triggerDrag(floatingBubbleEl, -100, -100);
|
||||
await vi.advanceTimersByTimeAsync(400);
|
||||
|
||||
await later(400);
|
||||
|
||||
expect(floatingBubbleEl.style.transform).toEqual(
|
||||
`translate3d(${window.innerWidth - 48 - 24}px, ${
|
||||
@ -197,20 +197,19 @@ test('should free direction move and magnetic to x axios when magnetic is "x" '
|
||||
);
|
||||
|
||||
await triggerDrag(floatingBubbleEl, -600, -100);
|
||||
await vi.advanceTimersByTimeAsync(400);
|
||||
|
||||
await later(400);
|
||||
|
||||
expect(floatingBubbleEl.style.transform).toEqual(
|
||||
`translate3d(${24}px, ${window.innerHeight - 48 - 24 - 200}px, 0)`,
|
||||
);
|
||||
|
||||
restore();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('should offset control positioning when use v-model:offset ', async () => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
|
||||
|
||||
const root = document.createElement('div');
|
||||
const wrapper = mount(FloatingBubble, {
|
||||
props: {
|
||||
@ -228,7 +227,8 @@ test('should offset control positioning when use v-model:offset ', async () => {
|
||||
)!;
|
||||
|
||||
await triggerDrag(floatingBubbleEl, 100, 100);
|
||||
await vi.advanceTimersByTimeAsync(400);
|
||||
|
||||
await later(400);
|
||||
|
||||
expect(floatingBubbleEl.style.transform).toEqual(
|
||||
`translate3d(${300}px, ${300}px, 0)`,
|
||||
@ -241,7 +241,6 @@ test('should offset control positioning when use v-model:offset ', async () => {
|
||||
});
|
||||
|
||||
restore();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('should emit click when click wrapper', async () => {
|
||||
|
||||
@ -10,17 +10,15 @@ import {
|
||||
} from '../function-call';
|
||||
|
||||
test('toast disappeared after duration', async () => {
|
||||
vi.useFakeTimers();
|
||||
const onClose = vi.fn();
|
||||
showToast({
|
||||
duration: 10,
|
||||
onClose,
|
||||
});
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
expect(onClose).toHaveBeenCalledTimes(0);
|
||||
await later(50);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('show loading toast', async () => {
|
||||
@ -33,19 +31,17 @@ test('show loading toast', async () => {
|
||||
});
|
||||
|
||||
test('show html toast', async () => {
|
||||
vi.useFakeTimers();
|
||||
showToast({
|
||||
type: 'html',
|
||||
className: 'html-toast',
|
||||
message: '<div>Message</div>',
|
||||
});
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
await later(1000);
|
||||
const toastText = document.querySelector(
|
||||
'.html-toast .van-toast__text',
|
||||
) as HTMLDivElement;
|
||||
expect(toastText.innerHTML).toEqual('<div>Message</div>');
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('icon prop', async () => {
|
||||
@ -112,15 +108,15 @@ test('clear multiple toast', async () => {
|
||||
});
|
||||
|
||||
test('remove toast DOM when cleared in multiple mode', async () => {
|
||||
vi.useFakeTimers();
|
||||
allowMultipleToast();
|
||||
closeToast(true);
|
||||
const toast = showToast({ className: 'remove-toast' });
|
||||
toast.close();
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
await later();
|
||||
|
||||
await toast.close();
|
||||
await later(100);
|
||||
expect(document.querySelector('.remove-toast')).toBeNull();
|
||||
allowMultipleToast(false);
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('set default options', async () => {
|
||||
@ -155,15 +151,13 @@ test('set default options by type', async () => {
|
||||
});
|
||||
|
||||
test('toast duration 0', async () => {
|
||||
vi.useFakeTimers();
|
||||
allowMultipleToast();
|
||||
const onClose = vi.fn();
|
||||
showToast({ duration: 0, onClose });
|
||||
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
await later(2100);
|
||||
expect(onClose).toHaveBeenCalledTimes(0);
|
||||
allowMultipleToast(false);
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test('should trigger onClose callback after closed', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user