Skip to content

Commit

Permalink
test(FloatingBubble): reduce test run time (#12539)
Browse files Browse the repository at this point in the history
  • Loading branch information
inottn authored Dec 30, 2023
1 parent 329cfcd commit 2cc4ca6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/vant/src/floating-bubble/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ 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 () => {
const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
vi.useFakeTimers();

const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
const root = document.createElement('div');
mount(FloatingBubble, {
props: {
Expand All @@ -187,8 +188,7 @@ test('should free direction move and magnetic to x axios when magnetic is "x" '
)!;

await triggerDrag(floatingBubbleEl, -100, -100);

await later(400);
await vi.advanceTimersByTimeAsync(400);

expect(floatingBubbleEl.style.transform).toEqual(
`translate3d(${window.innerWidth - 48 - 24}px, ${
Expand All @@ -197,19 +197,20 @@ test('should free direction move and magnetic to x axios when magnetic is "x" '
);

await triggerDrag(floatingBubbleEl, -600, -100);

await later(400);
await vi.advanceTimersByTimeAsync(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 () => {
const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
vi.useFakeTimers();

const restore = mockGetBoundingClientRect({ width: 48, height: 48 });
const root = document.createElement('div');
const wrapper = mount(FloatingBubble, {
props: {
Expand All @@ -227,8 +228,7 @@ test('should offset control positioning when use v-model:offset ', async () => {
)!;

await triggerDrag(floatingBubbleEl, 100, 100);

await later(400);
await vi.advanceTimersByTimeAsync(400);

expect(floatingBubbleEl.style.transform).toEqual(
`translate3d(${300}px, ${300}px, 0)`,
Expand All @@ -241,6 +241,7 @@ test('should offset control positioning when use v-model:offset ', async () => {
});

restore();
vi.useRealTimers();
});

test('should emit click when click wrapper', async () => {
Expand Down

0 comments on commit 2cc4ca6

Please sign in to comment.