Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emilkowalski committed Jan 15, 2025
1 parent b951a0d commit 9dfd67c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const Toast = (props: ToastProps) => {
const swipeDirections = props.swipeDirections ?? getDefaultSwipeDirections(position);

// Determine swipe direction if not already locked
if (!swipeDirection && (Math.abs(xDelta) > 5 || Math.abs(yDelta) > 5)) {
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y');
}

Expand Down
10 changes: 8 additions & 2 deletions test/tests/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ test.describe('Basic functionality', () => {
const dragBoundingBox = await toast.boundingBox();

if (!dragBoundingBox) return;
await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y);

// Initial touch point
await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y);
await page.mouse.down();
await page.mouse.move(0, dragBoundingBox.y + 300);

// Move mouse slightly to determine swipe direction
await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y + 10);

// Complete the swipe
await page.mouse.move(0, dragBoundingBox.y + 300);
await page.mouse.up();

await expect(page.getByTestId('dismiss-el')).toHaveCount(1);
});

Expand Down

0 comments on commit 9dfd67c

Please sign in to comment.