import { describe, it, expect, afterEach, vi } from "vitest"; import { mount } from "@vue/test-utils"; import { defineComponent } from "vue"; import { ColorFieldRoot, ColorFieldInput, ColorSliderRoot, ColorSliderTrack, ColorSliderThumb, } from "../../../packages/vue/tests/fixtures/color-probe"; const wrappers: ReturnType[] = []; afterEach(() => { wrappers.splice(0).forEach((w) => w.unmount()); vi.unstubAllGlobals(); }); describe("installed Reka color input audit, not public component acceptance", () => { it("emits hex for a polar channel edit", async () => { const w = mount( defineComponent({ components: { ColorFieldRoot, ColorFieldInput }, template: '', }), ); wrappers.push(w); await w.get("input").setValue("271"); await w.get("input").trigger("blur"); expect( w.getComponent(ColorFieldRoot).emitted("update:modelValue")?.[0]?.[0], ).toBe("#8080801f"); }); it("keeps optimistic slider state after a controlled parent rejection", async () => { vi.stubGlobal( "ResizeObserver", class { observe() {} unobserve() {} disconnect() {} }, ); const w = mount( defineComponent({ components: { ColorSliderRoot, ColorSliderTrack, ColorSliderThumb }, template: '', }), ); wrappers.push(w); await w.get('[role="slider"]').trigger("keydown", { key: "ArrowRight" }); expect( w.getComponent(ColorSliderRoot).emitted("update:modelValue")?.[0]?.[0], ).toMatch(/^#/); expect(w.get('[role="slider"]').attributes("aria-valuenow")).not.toBe( "270", ); }); });