clava 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,64 +0,0 @@
1
- import type { ComponentProps, JSX } from "solid-js";
2
- import { splitProps as splitSolidProps } from "solid-js";
3
- import { expect, expectTypeOf, test } from "vitest";
4
- import { type VariantProps, cv, splitProps } from "../src/index.ts";
5
- import { type HTMLObjProps } from "../src/types.ts";
6
-
7
- test("splitProps", () => {
8
- const component = cv({ variants: { size: { sm: "sm", md: "md" } } });
9
-
10
- interface Props
11
- extends ComponentProps<"div">, VariantProps<typeof component> {}
12
- const props: Props = { class: "custom", size: "md", id: "my-div" };
13
-
14
- const [variantProps, rest] = splitProps(props, component);
15
- expectTypeOf(variantProps.style).toEqualTypeOf<
16
- string | JSX.CSSProperties | undefined
17
- >();
18
- expectTypeOf(variantProps.class).toEqualTypeOf<string | undefined>();
19
- expect(variantProps.class).toBe("custom");
20
- expect(variantProps).toEqual({ size: "md", class: "custom" });
21
- expect(rest).toEqual({ id: "my-div" });
22
- });
23
-
24
- test("component props", () => {
25
- const component = cv({
26
- style: { fontSize: "16px" },
27
- variants: { size: { sm: "sm", md: "md" } },
28
- }).htmlObj;
29
- const props = component({ size: "sm", className: "custom" });
30
- expectTypeOf(props).toEqualTypeOf<HTMLObjProps>();
31
- expect(props).toEqual({
32
- class: "sm custom",
33
- style: { "font-size": "16px" },
34
- });
35
- });
36
-
37
- test("solid splitProps accepts html propKeys", () => {
38
- const component = cv({ variants: { size: { sm: "sm", md: "md" } } });
39
- expect(component.html.propKeys).toEqual(["class", "style", "size"]);
40
-
41
- interface Props
42
- extends ComponentProps<"button">, VariantProps<typeof component> {}
43
- const props: Props = { class: "custom", size: "md", id: "my-button" };
44
-
45
- const [variantProps, rest] = splitSolidProps(props, component.html.propKeys);
46
- expect(variantProps).toEqual({ class: "custom", size: "md" });
47
- expect(rest).toEqual({ id: "my-button" });
48
- });
49
-
50
- test("solid splitProps accepts htmlObj propKeys", () => {
51
- const component = cv({ variants: { size: { sm: "sm", md: "md" } } });
52
- expect(component.htmlObj.propKeys).toEqual(["class", "style", "size"]);
53
-
54
- interface Props
55
- extends ComponentProps<"button">, VariantProps<typeof component> {}
56
- const props: Props = { class: "custom", size: "md", id: "my-button" };
57
-
58
- const [variantProps, rest] = splitSolidProps(
59
- props,
60
- component.htmlObj.propKeys,
61
- );
62
- expect(variantProps).toEqual({ class: "custom", size: "md" });
63
- expect(rest).toEqual({ id: "my-button" });
64
- });