Refactored files.

This commit is contained in:
Jay
2025-08-01 20:24:19 -04:00
parent fa641c186c
commit c6118c8b0d
5 changed files with 125 additions and 140 deletions
+1
View File
@@ -118,6 +118,7 @@ const triggerMouseEvent = (eventType: string, x: number, y: number) => {
cy.dataCy("crosshair-container").trigger(eventType, {
clientX: x,
clientY: y,
buttons: 1,
eventConstructor: "MouseEvent",
});
};
+30 -36
View File
@@ -1,6 +1,7 @@
import { useState, useRef, useEffect } from "react";
import { useSlider, Direction } from "../slider";
import { useEffect, useRef, useState } from "react";
import type { CartesianSpace } from "../../types";
import { Direction, useSlider } from "../slider";
// Test Fixtures
@@ -111,6 +112,7 @@ function createTestUtils(isHorizontal = true) {
cy.dataCy("slider-container").trigger(eventType, {
clientX: x,
clientY: y,
buttons: 1,
eventConstructor: "MouseEvent",
});
};
@@ -176,28 +178,24 @@ describe("horizontal slider hook tests", () => {
assertPosition(164);
});
if (isTouchSupported()) {
it("moves the slider with touch events.", () => {
assertPosition(0);
it("moves the slider with touch events.", () => {
assertPosition(0);
triggerTouchEvent("touchstart", 86, 53);
assertPosition(0);
triggerTouchEvent("touchstart", 86, 53);
assertPosition(0);
triggerTouchEvent("touchmove", 150, 150);
assertPosition(64);
triggerTouchEvent("touchmove", 150, 150);
assertPosition(64);
triggerTouchEvent("touchmove", 500, 500);
assertPosition(250);
triggerTouchEvent("touchmove", 500, 500);
assertPosition(250);
triggerTouchEvent("touchmove", 250, 250);
assertPosition(164);
triggerTouchEvent("touchmove", 250, 250);
assertPosition(164);
triggerTouchEvent("touchend", 250, 250);
assertPosition(164);
});
} else {
console.log("Skipping Unsupported Touch Event Tests");
}
triggerTouchEvent("touchend", 250, 250);
assertPosition(164);
});
it("moves the slider with mouse wheel scrolling", () => {
assertPosition(0);
@@ -256,28 +254,24 @@ describe("vertical slider hook tests", () => {
assertPosition(172);
});
if (isTouchSupported()) {
it("moves the slider with touch events.", () => {
assertPosition(0);
it("moves the slider with touch events.", () => {
assertPosition(0);
triggerTouchEvent("touchstart", 86, 53);
assertPosition(0);
triggerTouchEvent("touchstart", 86, 53);
assertPosition(0);
triggerTouchEvent("touchmove", 150, 150);
assertPosition(72);
triggerTouchEvent("touchmove", 150, 150);
assertPosition(72);
triggerTouchEvent("touchmove", 500, 500);
assertPosition(250);
triggerTouchEvent("touchmove", 500, 500);
assertPosition(250);
triggerTouchEvent("touchmove", 250, 250);
assertPosition(172);
triggerTouchEvent("touchmove", 250, 250);
assertPosition(172);
triggerTouchEvent("touchend", 250, 250);
assertPosition(172);
});
} else {
console.log("Skipping Unsupported Touch Event Tests");
}
triggerTouchEvent("touchend", 250, 250);
assertPosition(172);
});
it("moves the slider with mouse wheel scrolling", () => {
assertPosition(0);