feat: migrate Slider with native range semantics and strict ESM declarations
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// @vitest-environment node
|
||||
import { expect, it } from "vitest";
|
||||
import { createSSRApp, h } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
Slider,
|
||||
SliderTrack,
|
||||
SliderFill,
|
||||
SliderThumb,
|
||||
SliderOutput,
|
||||
Label,
|
||||
} from "../packages/vue/src";
|
||||
it("renders explicit native range values, positions and composed label on the server", async () => {
|
||||
expect(typeof window).toBe("undefined");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h(Slider, { defaultValue: [20, 80] }, () => [
|
||||
h(Label, {}, () => "Price"),
|
||||
h(SliderOutput),
|
||||
h(SliderTrack, {}, () => [
|
||||
h(SliderFill),
|
||||
h(SliderThumb, { name: "min" }),
|
||||
h(SliderThumb, { index: 1, name: "max" }),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('aria-valuenow="20"');
|
||||
expect(html).toContain('aria-valuenow="80"');
|
||||
expect(html).toContain("left:20%");
|
||||
expect(html).toContain("left:80%");
|
||||
expect(html).not.toContain("display:none");
|
||||
const labelId = html.match(/<span[^>]*id="([^"]+)"/)?.[1];
|
||||
expect(labelId).toBeDefined();
|
||||
expect(html).toContain(`aria-labelledby="${labelId}"`);
|
||||
});
|
||||
Reference in New Issue
Block a user