fill method infrastructure ✓ 100.0%
Last updated: 2026-03-04T23:21:38.386Z
Metrics
LOC: 46
Complexity: 6
Params: 2
Coverage: 100.0% (21/21 lines, 7x executed)
Signature
fill(wrapper: HTMLElement, value: string): : boolean
Source Code
fill(wrapper: HTMLElement, value: string): boolean {
const handle = wrapper.querySelector<HTMLElement>(".ant-slider-handle");
if (!handle) return false;
const min = parseFloat(handle.getAttribute("aria-valuemin") ?? "0");
const max = parseFloat(handle.getAttribute("aria-valuemax") ?? "100");
let numericValue = parseFloat(value);
if (isNaN(numericValue)) {
// Generate a random value within the range
numericValue = min + Math.random() * (max - min);
}
// Clamp to range
numericValue = Math.max(min, Math.min(max, numericValue));
// Calculate percentage position
const percent = ((numericValue - min) / (max - min)) * 100;
// Update the handle
handle.setAttribute("aria-valuenow", String(Math.round(numericValue)));
handle.style.left = `${percent}%`;
// Update the track
const track = wrapper.querySelector<HTMLElement>(".ant-slider-track");
if (track) {
track.style.width = `${percent}%`;
}
// Simulate mouse events to trigger React state updates
const rect = wrapper.getBoundingClientRect();
const clientX = rect.left + (rect.width * percent) / 100;
const clientY = rect.top + rect.height / 2;
handle.dispatchEvent(
new MouseEvent("mousedown", { bubbles: true, clientX, clientY }),
);
document.dispatchEvent(
new MouseEvent("mousemove", { bubbles: true, clientX, clientY }),
);
document.dispatchEvent(
new MouseEvent("mouseup", { bubbles: true, clientX, clientY }),
);
return true;
},
No outgoing dependencies.
No incoming dependencies.