test: cover ColorSlider scoped slot reactivity

This commit is contained in:
maoyingjie
2026-10-27 09:17:52 +08:00
parent d58b36cdc6
commit d7dd2c2393
+10 -5
View File
@@ -823,18 +823,23 @@ describe("ColorSlider public contract", () => {
const w = slide(
{ defaultValue: "hsl(90,100%,50%)" },
`<ColorSlider v-bind="props" v-slot="root" channel="hue">
<span data-root-scope>{{ root.channel }} / {{ root.colorSpace }} / {{ root.orientation }}</span>
<span data-root-scope>{{ root.channel }} / {{ root.colorSpace }} / {{ root.orientation }} / {{ root.color.toString("hsl") }}</span>
<ColorSliderOutput v-slot="out"><span data-output-scope>{{ out.label }} / {{ out.value }}</span></ColorSliderOutput>
<ColorSliderTrack v-slot="track"><span data-track-scope>{{ Math.round(track.percent * 100) }}</span><ColorSliderThumb v-slot="thumb"><span data-thumb-scope>{{ thumb.isDragging ? "dragging" : "idle" }}</span></ColorSliderThumb></ColorSliderTrack>
<ColorSliderTrack v-slot="track"><span data-track-scope>{{ track.percent.toFixed(3) }}</span><ColorSliderThumb v-slot="thumb"><span data-thumb-scope>{{ thumb.isDragging ? "dragging" : "idle" }}</span></ColorSliderThumb></ColorSliderTrack>
</ColorSlider>`,
);
expect(w.get("[data-root-scope]").text()).toBe("hue / hsl / horizontal");
expect(w.get("[data-root-scope]").text()).toBe(
"hue / hsl / horizontal / hsl(90, 100%, 50%)",
);
expect(w.get("[data-output-scope]").text()).toBe("90° / 90");
expect(w.get("[data-track-scope]").text()).toBe("25");
expect(w.get("[data-track-scope]").text()).toBe("0.250");
expect(w.get("[data-thumb-scope]").text()).toBe("idle");
await key(w, "ArrowRight");
expect(w.get("[data-output-scope]").text()).toBe("91° / 91");
expect(w.get("[data-track-scope]").text()).toBe("25");
expect(w.get("[data-root-scope]").text()).toBe(
"hue / hsl / horizontal / hsl(91, 100%, 50%)",
);
expect(w.get("[data-track-scope]").text()).toBe("0.253");
});
it("associates Label, aria attributes, description and output with the input", async () => {