58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
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<typeof mount>[] = [];
|
|
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:
|
|
'<ColorFieldRoot default-value="hsb(270,0%,50%,.12345)" channel="hue" color-space="hsb"><ColorFieldInput/></ColorFieldRoot>',
|
|
}),
|
|
);
|
|
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:
|
|
'<ColorSliderRoot model-value="hsb(270,0%,50%)" channel="hue" color-space="hsb"><ColorSliderTrack><ColorSliderThumb/></ColorSliderTrack></ColorSliderRoot>',
|
|
}),
|
|
);
|
|
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",
|
|
);
|
|
});
|
|
});
|