@blueprintjs/labs 6.1.6 → 6.1.8
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.
- package/lib/cjs/components/box/box.test.js +12 -12
- package/lib/cjs/components/box/box.test.js.map +1 -1
- package/lib/cjs/components/flex/flex.test.js +8 -8
- package/lib/cjs/components/flex/flex.test.js.map +1 -1
- package/lib/cjs/components/slot/slot.test.js +6 -6
- package/lib/cjs/components/slot/slot.test.js.map +1 -1
- package/lib/esm/components/box/box.test.js +12 -12
- package/lib/esm/components/box/box.test.js.map +1 -1
- package/lib/esm/components/flex/flex.test.js +8 -8
- package/lib/esm/components/flex/flex.test.js.map +1 -1
- package/lib/esm/components/slot/slot.test.js +6 -6
- package/lib/esm/components/slot/slot.test.js.map +1 -1
- package/lib/esnext/components/box/box.test.js +12 -12
- package/lib/esnext/components/box/box.test.js.map +1 -1
- package/lib/esnext/components/flex/flex.test.js +8 -8
- package/lib/esnext/components/flex/flex.test.js.map +1 -1
- package/lib/esnext/components/slot/slot.test.js +6 -6
- package/lib/esnext/components/slot/slot.test.js.map +1 -1
- package/package.json +10 -11
- package/src/components/box/box.test.tsx +12 -12
- package/src/components/flex/flex.test.tsx +8 -8
- package/src/components/slot/slot.test.tsx +7 -6
- package/vitest.config.mts +2 -1
- package/vitest.setup.mts +0 -13
|
@@ -6,50 +6,50 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
*/
|
|
7
7
|
const react_1 = require("@testing-library/react");
|
|
8
8
|
const react_2 = require("react");
|
|
9
|
-
const vitest_1 = require("vitest");
|
|
10
9
|
const core_1 = require("@blueprintjs/core");
|
|
10
|
+
const vitest_1 = require("@blueprintjs/test-commons/vitest");
|
|
11
11
|
const common_1 = require("../../common");
|
|
12
12
|
const box_1 = require("./box");
|
|
13
13
|
const NS = common_1.Classes.getClassNamespace();
|
|
14
14
|
(0, vitest_1.describe)("<Box>", () => {
|
|
15
|
-
(0, vitest_1.
|
|
15
|
+
(0, vitest_1.test)("should render content", () => {
|
|
16
16
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { children: "Test" }));
|
|
17
17
|
const box = react_1.screen.getByText(/test/i);
|
|
18
18
|
(0, vitest_1.expect)(box).toBeInTheDocument();
|
|
19
19
|
});
|
|
20
|
-
(0, vitest_1.
|
|
20
|
+
(0, vitest_1.test)("should render as a div by default", () => {
|
|
21
21
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { children: "Test" }));
|
|
22
22
|
const box = react_1.screen.getByText(/test/i);
|
|
23
23
|
(0, vitest_1.expect)(box.tagName).toBe("DIV");
|
|
24
24
|
});
|
|
25
|
-
(0, vitest_1.
|
|
25
|
+
(0, vitest_1.test)("should pass through data attributes", () => {
|
|
26
26
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { "data-test": "foo", children: "Test" }));
|
|
27
27
|
const box = react_1.screen.getByText(/test/i);
|
|
28
28
|
(0, vitest_1.expect)(box.dataset.test).toBe("foo");
|
|
29
29
|
});
|
|
30
|
-
(0, vitest_1.
|
|
30
|
+
(0, vitest_1.test)("should support className", () => {
|
|
31
31
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { className: "foo", children: "Test" }));
|
|
32
32
|
const box = react_1.screen.getByText(/test/i);
|
|
33
33
|
(0, vitest_1.expect)(box).toHaveClass("foo");
|
|
34
34
|
});
|
|
35
|
-
(0, vitest_1.
|
|
35
|
+
(0, vitest_1.test)("should support style", () => {
|
|
36
36
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { style: { fontWeight: 700 }, children: "Test" }));
|
|
37
37
|
const box = react_1.screen.getByText(/test/i);
|
|
38
38
|
(0, vitest_1.expect)(box).toHaveStyle({ fontWeight: 700 });
|
|
39
39
|
});
|
|
40
|
-
(0, vitest_1.
|
|
40
|
+
(0, vitest_1.test)("should support computed class names", () => {
|
|
41
41
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { display: "flex", margin: 2, children: "Test" }));
|
|
42
42
|
const box = react_1.screen.getByText(/test/i);
|
|
43
43
|
(0, vitest_1.expect)(box).toHaveClass(`${NS}-flex`);
|
|
44
44
|
(0, vitest_1.expect)(box).toHaveClass(`${NS}-margin-2`);
|
|
45
45
|
});
|
|
46
|
-
(0, vitest_1.
|
|
46
|
+
(0, vitest_1.test)("should attach ref", () => {
|
|
47
47
|
const ref = (0, react_2.createRef)();
|
|
48
48
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { ref: ref, children: "Test" }));
|
|
49
49
|
(0, vitest_1.expect)(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
50
50
|
(0, vitest_1.expect)(ref.current).toBeInTheDocument();
|
|
51
51
|
});
|
|
52
|
-
(0, vitest_1.
|
|
52
|
+
(0, vitest_1.test)("should not support unsupported/invalid props in types", () => {
|
|
53
53
|
// "foo" is not a valid HTML attribute
|
|
54
54
|
// @ts-expect-error
|
|
55
55
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { foo: "bar", children: "Test" }));
|
|
@@ -57,7 +57,7 @@ const NS = common_1.Classes.getClassNamespace();
|
|
|
57
57
|
(0, vitest_1.expect)(box).toHaveAttribute("foo", "bar");
|
|
58
58
|
});
|
|
59
59
|
(0, vitest_1.describe)("asChild", () => {
|
|
60
|
-
(0, vitest_1.
|
|
60
|
+
(0, vitest_1.test)("should render as child with asChild prop", () => {
|
|
61
61
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { asChild: true, "data-test": "foo", children: (0, jsx_runtime_1.jsx)(core_1.Button, { intent: "primary", children: "Test" }) }));
|
|
62
62
|
const button = react_1.screen.getByRole("button", { name: /test/i });
|
|
63
63
|
(0, vitest_1.expect)(button).toHaveClass(common_1.Classes.BOX);
|
|
@@ -65,12 +65,12 @@ const NS = common_1.Classes.getClassNamespace();
|
|
|
65
65
|
(0, vitest_1.expect)(button).toHaveClass(core_1.Classes.INTENT_PRIMARY);
|
|
66
66
|
(0, vitest_1.expect)(button).toHaveAttribute("data-test", "foo");
|
|
67
67
|
});
|
|
68
|
-
(0, vitest_1.
|
|
68
|
+
(0, vitest_1.test)("should merge styles with asChild prop", () => {
|
|
69
69
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { asChild: true, style: { fontWeight: 700 }, children: (0, jsx_runtime_1.jsx)(core_1.Button, { style: { color: "blue" }, children: "Test" }) }));
|
|
70
70
|
const button = react_1.screen.getByRole("button", { name: /test/i });
|
|
71
71
|
(0, vitest_1.expect)(button).toHaveStyle({ fontWeight: 700 });
|
|
72
72
|
});
|
|
73
|
-
(0, vitest_1.
|
|
73
|
+
(0, vitest_1.test)("should remove margin on wrapped component", () => {
|
|
74
74
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(box_1.Box, { asChild: true, marginYEnd: 0, children: (0, jsx_runtime_1.jsx)(core_1.H1, { children: "Test" }) }));
|
|
75
75
|
const h1 = react_1.screen.getByRole("heading", { name: /test/i });
|
|
76
76
|
(0, vitest_1.expect)(h1).toHaveClass(`${NS}-margin-block-end-0`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";;;AAAA;;GAEG;AAEH,kDAAwD;AACxD,iCAAkC;
|
|
1
|
+
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";;;AAAA;;GAEG;AAEH,kDAAwD;AACxD,iCAAkC;AAElC,4CAAuE;AACvE,6DAA0E;AAE1E,yCAAuC;AAEvC,+BAA4B;AAE5B,MAAM,EAAE,GAAG,gBAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC,IAAA,iBAAQ,EAAC,OAAO,EAAE,GAAG,EAAE;IACnB,IAAA,aAAI,EAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,IAAA,cAAM,EAAC,uBA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CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,IAAA,aAAI,EAAC,2CAA2C,EAAE,GAAG,EAAE;YACnD,IAAA,cAAM,EACF,uBAAC,SAAG,IAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,YAC7B,uBAAC,SAAE,uBAAU,GACX,CACT,CAAC;YACF,MAAM,EAAE,GAAG,cAAM,CAAC,SAAS,CAAqB,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAE9E,IAAA,eAAM,EAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -5,40 +5,40 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
6
6
|
*/
|
|
7
7
|
const react_1 = require("@testing-library/react");
|
|
8
|
-
const vitest_1 = require("vitest");
|
|
9
8
|
const core_1 = require("@blueprintjs/core");
|
|
9
|
+
const vitest_1 = require("@blueprintjs/test-commons/vitest");
|
|
10
10
|
const common_1 = require("../../common");
|
|
11
11
|
const flex_1 = require("./flex");
|
|
12
12
|
const NS = common_1.Classes.getClassNamespace();
|
|
13
13
|
(0, vitest_1.describe)("<Flex>", () => {
|
|
14
|
-
(0, vitest_1.
|
|
14
|
+
(0, vitest_1.test)("should render content", () => {
|
|
15
15
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { children: "Test" }));
|
|
16
16
|
const flex = react_1.screen.getByText(/test/i);
|
|
17
17
|
(0, vitest_1.expect)(flex).toBeInTheDocument();
|
|
18
18
|
});
|
|
19
|
-
(0, vitest_1.
|
|
19
|
+
(0, vitest_1.test)("should always set display flex", () => {
|
|
20
20
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { children: "Test" }));
|
|
21
21
|
const flex = react_1.screen.getByText(/test/i);
|
|
22
22
|
(0, vitest_1.expect)(flex).toHaveClass(`${NS}-flex`);
|
|
23
23
|
});
|
|
24
|
-
(0, vitest_1.
|
|
24
|
+
(0, vitest_1.test)("should pass through Box props", () => {
|
|
25
25
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { gap: 2, flexDirection: "column", "data-testid": "flex-test", children: "Test" }));
|
|
26
26
|
const flex = react_1.screen.getByTestId("flex-test");
|
|
27
27
|
(0, vitest_1.expect)(flex).toHaveClass(`${NS}-gap-2`);
|
|
28
28
|
(0, vitest_1.expect)(flex).toHaveClass(`${NS}-flex-column`);
|
|
29
29
|
});
|
|
30
|
-
(0, vitest_1.
|
|
30
|
+
(0, vitest_1.test)("should support className", () => {
|
|
31
31
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { className: "custom-class", children: "Test" }));
|
|
32
32
|
const flex = react_1.screen.getByText(/test/i);
|
|
33
33
|
(0, vitest_1.expect)(flex).toHaveClass("custom-class");
|
|
34
34
|
(0, vitest_1.expect)(flex).toHaveClass(common_1.Classes.BOX);
|
|
35
35
|
});
|
|
36
|
-
(0, vitest_1.
|
|
36
|
+
(0, vitest_1.test)("should support style prop", () => {
|
|
37
37
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { style: { fontWeight: 700 }, children: "Test" }));
|
|
38
38
|
const flex = react_1.screen.getByText(/test/i);
|
|
39
39
|
(0, vitest_1.expect)(flex).toHaveStyle({ fontWeight: 700 });
|
|
40
40
|
});
|
|
41
|
-
(0, vitest_1.
|
|
41
|
+
(0, vitest_1.test)("should support asChild prop", () => {
|
|
42
42
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { asChild: true, gap: 2, children: (0, jsx_runtime_1.jsx)(core_1.Button, { intent: "primary", children: "Test" }) }));
|
|
43
43
|
const button = react_1.screen.getByRole("button", { name: /test/i });
|
|
44
44
|
(0, vitest_1.expect)(button).toHaveClass(common_1.Classes.BOX);
|
|
@@ -46,7 +46,7 @@ const NS = common_1.Classes.getClassNamespace();
|
|
|
46
46
|
(0, vitest_1.expect)(button).toHaveClass(`${NS}-flex`);
|
|
47
47
|
(0, vitest_1.expect)(button).toHaveClass(`${NS}-gap-2`);
|
|
48
48
|
});
|
|
49
|
-
(0, vitest_1.
|
|
49
|
+
(0, vitest_1.test)("should support all flex-related props", () => {
|
|
50
50
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(flex_1.Flex, { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", alignItems: "center", gap: 3, "data-testid": "flex-all-props", children: "Test" }));
|
|
51
51
|
const flex = react_1.screen.getByTestId("flex-all-props");
|
|
52
52
|
(0, vitest_1.expect)(flex).toHaveClass(`${NS}-flex-row`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";;;AAAA;;GAEG;AAEH,kDAAwD;
|
|
1
|
+
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";;;AAAA;;GAEG;AAEH,kDAAwD;AAExD,4CAAmE;AACnE,6DAA0E;AAE1E,yCAAuC;AAEvC,iCAA8B;AAE9B,MAAM,EAAE,GAAG,gBAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC,IAAA,iBAAQ,EAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,IAAA,aAAI,EAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,IAAA,cAAM,EAAC,uBAAC,WAAI,uBAAY,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,cAAM,CAAC,SAAS,CAAiB,OAAO,CAAC,CAAC;QAEvD,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,gCAAgC,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AAC,CAAC;QAC3C,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC5C,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACjD,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAC/C,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -6,16 +6,16 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
*/
|
|
7
7
|
const react_1 = require("@testing-library/react");
|
|
8
8
|
const react_2 = require("react");
|
|
9
|
-
const vitest_1 = require("vitest");
|
|
9
|
+
const vitest_1 = require("@blueprintjs/test-commons/vitest");
|
|
10
10
|
const slot_1 = require("./slot");
|
|
11
11
|
(0, vitest_1.describe)("<Slot>", () => {
|
|
12
|
-
(0, vitest_1.
|
|
12
|
+
(0, vitest_1.test)("merges props into a single child", () => {
|
|
13
13
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(slot_1.Slot, { "data-test": "bar", children: (0, jsx_runtime_1.jsx)("button", { id: "foo", children: "Test" }) }));
|
|
14
14
|
const button = react_1.screen.getByRole("button", { name: /test/i });
|
|
15
15
|
(0, vitest_1.expect)(button).toHaveAttribute("id", "foo");
|
|
16
16
|
(0, vitest_1.expect)(button).toHaveAttribute("data-test", "bar");
|
|
17
17
|
});
|
|
18
|
-
(0, vitest_1.
|
|
18
|
+
(0, vitest_1.test)("merges className and style", () => {
|
|
19
19
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(slot_1.Slot, { className: "outer", style: { fontWeight: 700 }, children: (0, jsx_runtime_1.jsx)("button", { className: "inner", style: { fontStyle: "italic" }, children: "Test" }) }));
|
|
20
20
|
const button = react_1.screen.getByRole("button", { name: /test/i });
|
|
21
21
|
(0, vitest_1.expect)(button).toHaveClass("outer");
|
|
@@ -23,17 +23,17 @@ const slot_1 = require("./slot");
|
|
|
23
23
|
(0, vitest_1.expect)(button).toHaveStyle({ fontWeight: 700 });
|
|
24
24
|
(0, vitest_1.expect)(button).toHaveStyle({ fontStyle: "italic" });
|
|
25
25
|
});
|
|
26
|
-
(0, vitest_1.
|
|
26
|
+
(0, vitest_1.test)("forwards ref to the child", () => {
|
|
27
27
|
const ref = (0, react_2.createRef)();
|
|
28
28
|
(0, react_1.render)((0, jsx_runtime_1.jsx)(slot_1.Slot, { ref: ref, children: (0, jsx_runtime_1.jsx)("button", { children: "Test" }) }));
|
|
29
29
|
(0, vitest_1.expect)(ref.current).toBeInstanceOf(HTMLButtonElement);
|
|
30
30
|
(0, vitest_1.expect)(ref.current).toBeInTheDocument();
|
|
31
31
|
});
|
|
32
|
-
(0, vitest_1.
|
|
32
|
+
(0, vitest_1.test)("returns null if no children are provided", () => {
|
|
33
33
|
const { container } = (0, react_1.render)((0, jsx_runtime_1.jsx)(slot_1.Slot, {}));
|
|
34
34
|
(0, vitest_1.expect)(container.firstChild).toBeNull();
|
|
35
35
|
});
|
|
36
|
-
(0, vitest_1.
|
|
36
|
+
(0, vitest_1.test)("throws an error when multiple children are provided", () => {
|
|
37
37
|
// suppress error logging to keep test output clean
|
|
38
38
|
const stderrWriteSpy = vitest_1.vi.spyOn(process.stderr, "write").mockImplementation(vitest_1.vi.fn());
|
|
39
39
|
const consoleErrorSpy = vitest_1.vi.spyOn(console, "error").mockImplementation(vitest_1.vi.fn());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":";;;AAAA;;GAEG;AAEH,kDAAwD;AACxD,iCAAkC;
|
|
1
|
+
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/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AE3D,cAAc,CAAC,WAAW,EAAE,CAAC;QAC7B,eAAe,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -4,50 +4,50 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
7
|
import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
|
|
8
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
9
9
|
import { Classes } from "../../common";
|
|
10
10
|
import { Box } from "./box";
|
|
11
11
|
const NS = Classes.getClassNamespace();
|
|
12
12
|
describe("<Box>", () => {
|
|
13
|
-
|
|
13
|
+
test("should render content", () => {
|
|
14
14
|
render(_jsx(Box, { children: "Test" }));
|
|
15
15
|
const box = screen.getByText(/test/i);
|
|
16
16
|
expect(box).toBeInTheDocument();
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
test("should render as a div by default", () => {
|
|
19
19
|
render(_jsx(Box, { children: "Test" }));
|
|
20
20
|
const box = screen.getByText(/test/i);
|
|
21
21
|
expect(box.tagName).toBe("DIV");
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
test("should pass through data attributes", () => {
|
|
24
24
|
render(_jsx(Box, { "data-test": "foo", children: "Test" }));
|
|
25
25
|
const box = screen.getByText(/test/i);
|
|
26
26
|
expect(box.dataset.test).toBe("foo");
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
test("should support className", () => {
|
|
29
29
|
render(_jsx(Box, { className: "foo", children: "Test" }));
|
|
30
30
|
const box = screen.getByText(/test/i);
|
|
31
31
|
expect(box).toHaveClass("foo");
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
test("should support style", () => {
|
|
34
34
|
render(_jsx(Box, { style: { fontWeight: 700 }, children: "Test" }));
|
|
35
35
|
const box = screen.getByText(/test/i);
|
|
36
36
|
expect(box).toHaveStyle({ fontWeight: 700 });
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
test("should support computed class names", () => {
|
|
39
39
|
render(_jsx(Box, { display: "flex", margin: 2, children: "Test" }));
|
|
40
40
|
const box = screen.getByText(/test/i);
|
|
41
41
|
expect(box).toHaveClass(`${NS}-flex`);
|
|
42
42
|
expect(box).toHaveClass(`${NS}-margin-2`);
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
test("should attach ref", () => {
|
|
45
45
|
const ref = createRef();
|
|
46
46
|
render(_jsx(Box, { ref: ref, children: "Test" }));
|
|
47
47
|
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
48
48
|
expect(ref.current).toBeInTheDocument();
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
test("should not support unsupported/invalid props in types", () => {
|
|
51
51
|
// "foo" is not a valid HTML attribute
|
|
52
52
|
// @ts-expect-error
|
|
53
53
|
render(_jsx(Box, { foo: "bar", children: "Test" }));
|
|
@@ -55,7 +55,7 @@ describe("<Box>", () => {
|
|
|
55
55
|
expect(box).toHaveAttribute("foo", "bar");
|
|
56
56
|
});
|
|
57
57
|
describe("asChild", () => {
|
|
58
|
-
|
|
58
|
+
test("should render as child with asChild prop", () => {
|
|
59
59
|
render(_jsx(Box, { asChild: true, "data-test": "foo", children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
60
60
|
const button = screen.getByRole("button", { name: /test/i });
|
|
61
61
|
expect(button).toHaveClass(Classes.BOX);
|
|
@@ -63,12 +63,12 @@ describe("<Box>", () => {
|
|
|
63
63
|
expect(button).toHaveClass(CoreClasses.INTENT_PRIMARY);
|
|
64
64
|
expect(button).toHaveAttribute("data-test", "foo");
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
test("should merge styles with asChild prop", () => {
|
|
67
67
|
render(_jsx(Box, { asChild: true, style: { fontWeight: 700 }, children: _jsx(Button, { style: { color: "blue" }, children: "Test" }) }));
|
|
68
68
|
const button = screen.getByRole("button", { name: /test/i });
|
|
69
69
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
test("should remove margin on wrapped component", () => {
|
|
72
72
|
render(_jsx(Box, { asChild: true, marginYEnd: 0, children: _jsx(H1, { children: "Test" }) }));
|
|
73
73
|
const h1 = screen.getByRole("heading", { name: /test/i });
|
|
74
74
|
expect(h1).toHaveClass(`${NS}-margin-block-end-0`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACnB,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,KAAC,GAAG,uBAAW,CAAC,CAAC;QACxB,MAAM,GAAG,GAAG,MAA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EAAE,CAAC,CAAC;YAE9E,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -3,40 +3,40 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
6
|
import { Button, Classes as CoreClasses } from "@blueprintjs/core";
|
|
7
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
8
8
|
import { Classes } from "../../common";
|
|
9
9
|
import { Flex } from "./flex";
|
|
10
10
|
const NS = Classes.getClassNamespace();
|
|
11
11
|
describe("<Flex>", () => {
|
|
12
|
-
|
|
12
|
+
test("should render content", () => {
|
|
13
13
|
render(_jsx(Flex, { children: "Test" }));
|
|
14
14
|
const flex = screen.getByText(/test/i);
|
|
15
15
|
expect(flex).toBeInTheDocument();
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
test("should always set display flex", () => {
|
|
18
18
|
render(_jsx(Flex, { children: "Test" }));
|
|
19
19
|
const flex = screen.getByText(/test/i);
|
|
20
20
|
expect(flex).toHaveClass(`${NS}-flex`);
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
test("should pass through Box props", () => {
|
|
23
23
|
render(_jsx(Flex, { gap: 2, flexDirection: "column", "data-testid": "flex-test", children: "Test" }));
|
|
24
24
|
const flex = screen.getByTestId("flex-test");
|
|
25
25
|
expect(flex).toHaveClass(`${NS}-gap-2`);
|
|
26
26
|
expect(flex).toHaveClass(`${NS}-flex-column`);
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
test("should support className", () => {
|
|
29
29
|
render(_jsx(Flex, { className: "custom-class", children: "Test" }));
|
|
30
30
|
const flex = screen.getByText(/test/i);
|
|
31
31
|
expect(flex).toHaveClass("custom-class");
|
|
32
32
|
expect(flex).toHaveClass(Classes.BOX);
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
test("should support style prop", () => {
|
|
35
35
|
render(_jsx(Flex, { style: { fontWeight: 700 }, children: "Test" }));
|
|
36
36
|
const flex = screen.getByText(/test/i);
|
|
37
37
|
expect(flex).toHaveStyle({ fontWeight: 700 });
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
test("should support asChild prop", () => {
|
|
40
40
|
render(_jsx(Flex, { asChild: true, gap: 2, children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
41
41
|
const button = screen.getByRole("button", { name: /test/i });
|
|
42
42
|
expect(button).toHaveClass(Classes.BOX);
|
|
@@ -44,7 +44,7 @@ describe("<Flex>", () => {
|
|
|
44
44
|
expect(button).toHaveClass(`${NS}-flex`);
|
|
45
45
|
expect(button).toHaveClass(`${NS}-gap-2`);
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
test("should support all flex-related props", () => {
|
|
48
48
|
render(_jsx(Flex, { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", alignItems: "center", gap: 3, "data-testid": "flex-all-props", children: "Test" }));
|
|
49
49
|
const flex = screen.getByTestId("flex-all-props");
|
|
50
50
|
expect(flex).toHaveClass(`${NS}-flex-row`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,OAAO,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,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CACF,KAAC,IAAI,IACD,aAAa,EAAC,KAAK,EACnB,QAAQ,EAAC,MAAM,EACf,cAAc,EAAC,QAAQ,EACvB,UAAU,EAAC,QAAQ,EACnB,GAAG,EAAE,CAAC,iBACM,gBAAgB,qBAGzB,CACV,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAElD,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -4,16 +4,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect,
|
|
7
|
+
import { describe, expect, test, vi } from "@blueprintjs/test-commons/vitest";
|
|
8
8
|
import { Slot } from "./slot";
|
|
9
9
|
describe("<Slot>", () => {
|
|
10
|
-
|
|
10
|
+
test("merges props into a single child", () => {
|
|
11
11
|
render(_jsx(Slot, { "data-test": "bar", children: _jsx("button", { id: "foo", children: "Test" }) }));
|
|
12
12
|
const button = screen.getByRole("button", { name: /test/i });
|
|
13
13
|
expect(button).toHaveAttribute("id", "foo");
|
|
14
14
|
expect(button).toHaveAttribute("data-test", "bar");
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
test("merges className and style", () => {
|
|
17
17
|
render(_jsx(Slot, { className: "outer", style: { fontWeight: 700 }, children: _jsx("button", { className: "inner", style: { fontStyle: "italic" }, children: "Test" }) }));
|
|
18
18
|
const button = screen.getByRole("button", { name: /test/i });
|
|
19
19
|
expect(button).toHaveClass("outer");
|
|
@@ -21,17 +21,17 @@ describe("<Slot>", () => {
|
|
|
21
21
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
22
22
|
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
test("forwards ref to the child", () => {
|
|
25
25
|
const ref = createRef();
|
|
26
26
|
render(_jsx(Slot, { ref: ref, children: _jsx("button", { children: "Test" }) }));
|
|
27
27
|
expect(ref.current).toBeInstanceOf(HTMLButtonElement);
|
|
28
28
|
expect(ref.current).toBeInTheDocument();
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
test("returns null if no children are provided", () => {
|
|
31
31
|
const { container } = render(_jsx(Slot, {}));
|
|
32
32
|
expect(container.firstChild).toBeNull();
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
test("throws an error when multiple children are provided", () => {
|
|
35
35
|
// suppress error logging to keep test output clean
|
|
36
36
|
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
37
37
|
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,C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,MAAC,IAAI,eACD,qCAAsB,EACtB,sCAAuB,IACpB,CACV,CAAC;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;QAE3D,cAAc,CAAC,WAAW,EAAE,CAAC;QAC7B,eAAe,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -4,50 +4,50 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
7
|
import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
|
|
8
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
9
9
|
import { Classes } from "../../common";
|
|
10
10
|
import { Box } from "./box";
|
|
11
11
|
const NS = Classes.getClassNamespace();
|
|
12
12
|
describe("<Box>", () => {
|
|
13
|
-
|
|
13
|
+
test("should render content", () => {
|
|
14
14
|
render(_jsx(Box, { children: "Test" }));
|
|
15
15
|
const box = screen.getByText(/test/i);
|
|
16
16
|
expect(box).toBeInTheDocument();
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
test("should render as a div by default", () => {
|
|
19
19
|
render(_jsx(Box, { children: "Test" }));
|
|
20
20
|
const box = screen.getByText(/test/i);
|
|
21
21
|
expect(box.tagName).toBe("DIV");
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
test("should pass through data attributes", () => {
|
|
24
24
|
render(_jsx(Box, { "data-test": "foo", children: "Test" }));
|
|
25
25
|
const box = screen.getByText(/test/i);
|
|
26
26
|
expect(box.dataset.test).toBe("foo");
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
test("should support className", () => {
|
|
29
29
|
render(_jsx(Box, { className: "foo", children: "Test" }));
|
|
30
30
|
const box = screen.getByText(/test/i);
|
|
31
31
|
expect(box).toHaveClass("foo");
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
test("should support style", () => {
|
|
34
34
|
render(_jsx(Box, { style: { fontWeight: 700 }, children: "Test" }));
|
|
35
35
|
const box = screen.getByText(/test/i);
|
|
36
36
|
expect(box).toHaveStyle({ fontWeight: 700 });
|
|
37
37
|
});
|
|
38
|
-
|
|
38
|
+
test("should support computed class names", () => {
|
|
39
39
|
render(_jsx(Box, { display: "flex", margin: 2, children: "Test" }));
|
|
40
40
|
const box = screen.getByText(/test/i);
|
|
41
41
|
expect(box).toHaveClass(`${NS}-flex`);
|
|
42
42
|
expect(box).toHaveClass(`${NS}-margin-2`);
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
test("should attach ref", () => {
|
|
45
45
|
const ref = createRef();
|
|
46
46
|
render(_jsx(Box, { ref: ref, children: "Test" }));
|
|
47
47
|
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
48
48
|
expect(ref.current).toBeInTheDocument();
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
test("should not support unsupported/invalid props in types", () => {
|
|
51
51
|
// "foo" is not a valid HTML attribute
|
|
52
52
|
// @ts-expect-error
|
|
53
53
|
render(_jsx(Box, { foo: "bar", children: "Test" }));
|
|
@@ -55,7 +55,7 @@ describe("<Box>", () => {
|
|
|
55
55
|
expect(box).toHaveAttribute("foo", "bar");
|
|
56
56
|
});
|
|
57
57
|
describe("asChild", () => {
|
|
58
|
-
|
|
58
|
+
test("should render as child with asChild prop", () => {
|
|
59
59
|
render(_jsx(Box, { asChild: true, "data-test": "foo", children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
60
60
|
const button = screen.getByRole("button", { name: /test/i });
|
|
61
61
|
expect(button).toHaveClass(Classes.BOX);
|
|
@@ -63,12 +63,12 @@ describe("<Box>", () => {
|
|
|
63
63
|
expect(button).toHaveClass(CoreClasses.INTENT_PRIMARY);
|
|
64
64
|
expect(button).toHaveAttribute("data-test", "foo");
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
test("should merge styles with asChild prop", () => {
|
|
67
67
|
render(_jsx(Box, { asChild: true, style: { fontWeight: 700 }, children: _jsx(Button, { style: { color: "blue" }, children: "Test" }) }));
|
|
68
68
|
const button = screen.getByRole("button", { name: /test/i });
|
|
69
69
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
test("should remove margin on wrapped component", () => {
|
|
72
72
|
render(_jsx(Box, { asChild: true, marginYEnd: 0, children: _jsx(H1, { children: "Test" }) }));
|
|
73
73
|
const h1 = screen.getByRole("heading", { name: /test/i });
|
|
74
74
|
expect(h1).toHaveClass(`${NS}-margin-block-end-0`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACnB,IA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,EAAE,uBAAU,GACX,CACT,CAAC;YACF,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAqB,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAE9E,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -3,40 +3,40 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
6
|
import { Button, Classes as CoreClasses } from "@blueprintjs/core";
|
|
7
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
8
8
|
import { Classes } from "../../common";
|
|
9
9
|
import { Flex } from "./flex";
|
|
10
10
|
const NS = Classes.getClassNamespace();
|
|
11
11
|
describe("<Flex>", () => {
|
|
12
|
-
|
|
12
|
+
test("should render content", () => {
|
|
13
13
|
render(_jsx(Flex, { children: "Test" }));
|
|
14
14
|
const flex = screen.getByText(/test/i);
|
|
15
15
|
expect(flex).toBeInTheDocument();
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
test("should always set display flex", () => {
|
|
18
18
|
render(_jsx(Flex, { children: "Test" }));
|
|
19
19
|
const flex = screen.getByText(/test/i);
|
|
20
20
|
expect(flex).toHaveClass(`${NS}-flex`);
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
test("should pass through Box props", () => {
|
|
23
23
|
render(_jsx(Flex, { gap: 2, flexDirection: "column", "data-testid": "flex-test", children: "Test" }));
|
|
24
24
|
const flex = screen.getByTestId("flex-test");
|
|
25
25
|
expect(flex).toHaveClass(`${NS}-gap-2`);
|
|
26
26
|
expect(flex).toHaveClass(`${NS}-flex-column`);
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
test("should support className", () => {
|
|
29
29
|
render(_jsx(Flex, { className: "custom-class", children: "Test" }));
|
|
30
30
|
const flex = screen.getByText(/test/i);
|
|
31
31
|
expect(flex).toHaveClass("custom-class");
|
|
32
32
|
expect(flex).toHaveClass(Classes.BOX);
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
test("should support style prop", () => {
|
|
35
35
|
render(_jsx(Flex, { style: { fontWeight: 700 }, children: "Test" }));
|
|
36
36
|
const flex = screen.getByText(/test/i);
|
|
37
37
|
expect(flex).toHaveStyle({ fontWeight: 700 });
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
test("should support asChild prop", () => {
|
|
40
40
|
render(_jsx(Flex, { asChild: true, gap: 2, children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
41
41
|
const button = screen.getByRole("button", { name: /test/i });
|
|
42
42
|
expect(button).toHaveClass(Classes.BOX);
|
|
@@ -44,7 +44,7 @@ describe("<Flex>", () => {
|
|
|
44
44
|
expect(button).toHaveClass(`${NS}-flex`);
|
|
45
45
|
expect(button).toHaveClass(`${NS}-gap-2`);
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
test("should support all flex-related props", () => {
|
|
48
48
|
render(_jsx(Flex, { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", alignItems: "center", gap: 3, "data-testid": "flex-all-props", children: "Test" }));
|
|
49
49
|
const flex = screen.getByTestId("flex-all-props");
|
|
50
50
|
expect(flex).toHaveClass(`${NS}-flex-row`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings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CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CACF,KAAC,IAAI,IACD,aAAa,EAAC,KAAK,EACnB,QAAQ,EAAC,MAAM,EACf,cAAc,EAAC,QAAQ,EACvB,UAAU,EAAC,QAAQ,EACnB,GAAG,EAAE,CAAC,iBACM,gBAAgB,qBAGzB,CACV,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAElD,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -4,16 +4,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect,
|
|
7
|
+
import { describe, expect, test, vi } from "@blueprintjs/test-commons/vitest";
|
|
8
8
|
import { Slot } from "./slot";
|
|
9
9
|
describe("<Slot>", () => {
|
|
10
|
-
|
|
10
|
+
test("merges props into a single child", () => {
|
|
11
11
|
render(_jsx(Slot, { "data-test": "bar", children: _jsx("button", { id: "foo", children: "Test" }) }));
|
|
12
12
|
const button = screen.getByRole("button", { name: /test/i });
|
|
13
13
|
expect(button).toHaveAttribute("id", "foo");
|
|
14
14
|
expect(button).toHaveAttribute("data-test", "bar");
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
test("merges className and style", () => {
|
|
17
17
|
render(_jsx(Slot, { className: "outer", style: { fontWeight: 700 }, children: _jsx("button", { className: "inner", style: { fontStyle: "italic" }, children: "Test" }) }));
|
|
18
18
|
const button = screen.getByRole("button", { name: /test/i });
|
|
19
19
|
expect(button).toHaveClass("outer");
|
|
@@ -21,17 +21,17 @@ describe("<Slot>", () => {
|
|
|
21
21
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
22
22
|
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
test("forwards ref to the child", () => {
|
|
25
25
|
const ref = createRef();
|
|
26
26
|
render(_jsx(Slot, { ref: ref, children: _jsx("button", { children: "Test" }) }));
|
|
27
27
|
expect(ref.current).toBeInstanceOf(HTMLButtonElement);
|
|
28
28
|
expect(ref.current).toBeInTheDocument();
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
test("returns null if no children are provided", () => {
|
|
31
31
|
const { container } = render(_jsx(Slot, {}));
|
|
32
32
|
expect(container.firstChild).toBeNull();
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
test("throws an error when multiple children are provided", () => {
|
|
35
35
|
// suppress error logging to keep test output clean
|
|
36
36
|
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
37
37
|
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":";AAAA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OAAO,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAE/E,MAAM,CAAC,GAAG,EAAE;YACR,MAAM,CACF,MAAC,IAAI,eACD,qCAAsB,EACtB,sCAAuB,IACpB,CACV,CAAC;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;QAE3D,cAAc,CAAC,WAAW,EAAE,CAAC;QAC7B,eAAe,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueprintjs/labs",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.8",
|
|
4
4
|
"description": "Incubator for unstable and in-development Blueprint components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"classnames": "^2.3.1",
|
|
12
12
|
"tslib": "~2.6.2",
|
|
13
|
-
"@blueprintjs/
|
|
14
|
-
"@blueprintjs/
|
|
13
|
+
"@blueprintjs/colors": "^5.1.14",
|
|
14
|
+
"@blueprintjs/core": "^6.8.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@types/react": "18",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@testing-library/dom": "^10.4.
|
|
27
|
+
"@testing-library/dom": "^10.4.0",
|
|
28
28
|
"@testing-library/jest-dom": "^6.9.1",
|
|
29
|
-
"@testing-library/react": "^16.
|
|
29
|
+
"@testing-library/react": "^16.1.0",
|
|
30
30
|
"@testing-library/user-event": "^14.6.1",
|
|
31
31
|
"@vitejs/plugin-react": "^5.1.0",
|
|
32
32
|
"jsdom": "^27.1.0",
|
|
@@ -34,12 +34,11 @@
|
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
36
36
|
"typescript": "~5.3.3",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@blueprintjs/test-commons": "^4.0.
|
|
40
|
-
"@blueprintjs/
|
|
41
|
-
"@blueprintjs/
|
|
42
|
-
"@blueprintjs/webpack-build-scripts": "^6.2.15"
|
|
37
|
+
"vitest": "4.0.7",
|
|
38
|
+
"@blueprintjs/node-build-scripts": "^9.3.1",
|
|
39
|
+
"@blueprintjs/test-commons": "^4.0.4",
|
|
40
|
+
"@blueprintjs/stylelint-plugin": "^5.2.0",
|
|
41
|
+
"@blueprintjs/webpack-build-scripts": "^6.2.16"
|
|
43
42
|
},
|
|
44
43
|
"repository": {
|
|
45
44
|
"type": "git",
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
7
|
|
|
9
8
|
import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
|
|
9
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
10
10
|
|
|
11
11
|
import { Classes } from "../../common";
|
|
12
12
|
|
|
@@ -15,42 +15,42 @@ import { Box } from "./box";
|
|
|
15
15
|
const NS = Classes.getClassNamespace();
|
|
16
16
|
|
|
17
17
|
describe("<Box>", () => {
|
|
18
|
-
|
|
18
|
+
test("should render content", () => {
|
|
19
19
|
render(<Box>Test</Box>);
|
|
20
20
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
21
21
|
|
|
22
22
|
expect(box).toBeInTheDocument();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
test("should render as a div by default", () => {
|
|
26
26
|
render(<Box>Test</Box>);
|
|
27
27
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
28
28
|
|
|
29
29
|
expect(box.tagName).toBe("DIV");
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
test("should pass through data attributes", () => {
|
|
33
33
|
render(<Box data-test="foo">Test</Box>);
|
|
34
34
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
35
35
|
|
|
36
36
|
expect(box.dataset.test).toBe("foo");
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
test("should support className", () => {
|
|
40
40
|
render(<Box className="foo">Test</Box>);
|
|
41
41
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
42
42
|
|
|
43
43
|
expect(box).toHaveClass("foo");
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
test("should support style", () => {
|
|
47
47
|
render(<Box style={{ fontWeight: 700 }}>Test</Box>);
|
|
48
48
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
49
49
|
|
|
50
50
|
expect(box).toHaveStyle({ fontWeight: 700 });
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
test("should support computed class names", () => {
|
|
54
54
|
render(
|
|
55
55
|
<Box display="flex" margin={2}>
|
|
56
56
|
Test
|
|
@@ -62,7 +62,7 @@ describe("<Box>", () => {
|
|
|
62
62
|
expect(box).toHaveClass(`${NS}-margin-2`);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
test("should attach ref", () => {
|
|
66
66
|
const ref = createRef<HTMLDivElement>();
|
|
67
67
|
render(<Box ref={ref}>Test</Box>);
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ describe("<Box>", () => {
|
|
|
70
70
|
expect(ref.current).toBeInTheDocument();
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
test("should not support unsupported/invalid props in types", () => {
|
|
74
74
|
// "foo" is not a valid HTML attribute
|
|
75
75
|
// @ts-expect-error
|
|
76
76
|
render(<Box foo="bar">Test</Box>);
|
|
@@ -80,7 +80,7 @@ describe("<Box>", () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
describe("asChild", () => {
|
|
83
|
-
|
|
83
|
+
test("should render as child with asChild prop", () => {
|
|
84
84
|
render(
|
|
85
85
|
<Box asChild={true} data-test="foo">
|
|
86
86
|
<Button intent="primary">Test</Button>
|
|
@@ -94,7 +94,7 @@ describe("<Box>", () => {
|
|
|
94
94
|
expect(button).toHaveAttribute("data-test", "foo");
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
test("should merge styles with asChild prop", () => {
|
|
98
98
|
render(
|
|
99
99
|
<Box asChild={true} style={{ fontWeight: 700 }}>
|
|
100
100
|
<Button style={{ color: "blue" }}>Test</Button>
|
|
@@ -105,7 +105,7 @@ describe("<Box>", () => {
|
|
|
105
105
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
test("should remove margin on wrapped component", () => {
|
|
109
109
|
render(
|
|
110
110
|
<Box asChild={true} marginYEnd={0}>
|
|
111
111
|
<H1>Test</H1>
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
6
|
|
|
8
7
|
import { Button, Classes as CoreClasses } from "@blueprintjs/core";
|
|
8
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
9
9
|
|
|
10
10
|
import { Classes } from "../../common";
|
|
11
11
|
|
|
@@ -14,21 +14,21 @@ import { Flex } from "./flex";
|
|
|
14
14
|
const NS = Classes.getClassNamespace();
|
|
15
15
|
|
|
16
16
|
describe("<Flex>", () => {
|
|
17
|
-
|
|
17
|
+
test("should render content", () => {
|
|
18
18
|
render(<Flex>Test</Flex>);
|
|
19
19
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
20
20
|
|
|
21
21
|
expect(flex).toBeInTheDocument();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
test("should always set display flex", () => {
|
|
25
25
|
render(<Flex>Test</Flex>);
|
|
26
26
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
27
27
|
|
|
28
28
|
expect(flex).toHaveClass(`${NS}-flex`);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
test("should pass through Box props", () => {
|
|
32
32
|
render(
|
|
33
33
|
<Flex gap={2} flexDirection="column" data-testid="flex-test">
|
|
34
34
|
Test
|
|
@@ -40,7 +40,7 @@ describe("<Flex>", () => {
|
|
|
40
40
|
expect(flex).toHaveClass(`${NS}-flex-column`);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
test("should support className", () => {
|
|
44
44
|
render(<Flex className="custom-class">Test</Flex>);
|
|
45
45
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
46
46
|
|
|
@@ -48,14 +48,14 @@ describe("<Flex>", () => {
|
|
|
48
48
|
expect(flex).toHaveClass(Classes.BOX);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
test("should support style prop", () => {
|
|
52
52
|
render(<Flex style={{ fontWeight: 700 }}>Test</Flex>);
|
|
53
53
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
54
54
|
|
|
55
55
|
expect(flex).toHaveStyle({ fontWeight: 700 });
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
test("should support asChild prop", () => {
|
|
59
59
|
render(
|
|
60
60
|
<Flex asChild={true} gap={2}>
|
|
61
61
|
<Button intent="primary">Test</Button>
|
|
@@ -69,7 +69,7 @@ describe("<Flex>", () => {
|
|
|
69
69
|
expect(button).toHaveClass(`${NS}-gap-2`);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
test("should support all flex-related props", () => {
|
|
73
73
|
render(
|
|
74
74
|
<Flex
|
|
75
75
|
flexDirection="row"
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import { describe, expect, test, vi } from "@blueprintjs/test-commons/vitest";
|
|
8
9
|
|
|
9
10
|
import { Slot } from "./slot";
|
|
10
11
|
|
|
11
12
|
describe("<Slot>", () => {
|
|
12
|
-
|
|
13
|
+
test("merges props into a single child", () => {
|
|
13
14
|
render(
|
|
14
15
|
<Slot data-test="bar">
|
|
15
16
|
<button id="foo">Test</button>
|
|
@@ -21,7 +22,7 @@ describe("<Slot>", () => {
|
|
|
21
22
|
expect(button).toHaveAttribute("data-test", "bar");
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
test("merges className and style", () => {
|
|
25
26
|
render(
|
|
26
27
|
<Slot className="outer" style={{ fontWeight: 700 }}>
|
|
27
28
|
<button className="inner" style={{ fontStyle: "italic" }}>
|
|
@@ -37,7 +38,7 @@ describe("<Slot>", () => {
|
|
|
37
38
|
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
test("forwards ref to the child", () => {
|
|
41
42
|
const ref = createRef<HTMLButtonElement>();
|
|
42
43
|
render(
|
|
43
44
|
<Slot ref={ref}>
|
|
@@ -48,12 +49,12 @@ describe("<Slot>", () => {
|
|
|
48
49
|
expect(ref.current).toBeInTheDocument();
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
test("returns null if no children are provided", () => {
|
|
52
53
|
const { container } = render(<Slot />);
|
|
53
54
|
expect(container.firstChild).toBeNull();
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
test("throws an error when multiple children are provided", () => {
|
|
57
58
|
// suppress error logging to keep test output clean
|
|
58
59
|
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
59
60
|
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
package/vitest.config.mts
CHANGED
|
@@ -9,9 +9,10 @@ import { defineConfig } from "vitest/config";
|
|
|
9
9
|
export default defineConfig({
|
|
10
10
|
plugins: [react()],
|
|
11
11
|
test: {
|
|
12
|
+
name: "labs",
|
|
12
13
|
environment: "jsdom",
|
|
13
14
|
exclude: ["lib/**", "node_modules/**"],
|
|
14
15
|
include: ["src/**/*.{test,spec}.{ts,tsx}"],
|
|
15
|
-
setupFiles: "
|
|
16
|
+
setupFiles: "@blueprintjs/test-commons/vitest-setup-no-enzyme",
|
|
16
17
|
},
|
|
17
18
|
});
|
package/vitest.setup.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* !
|
|
2
|
-
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom/vitest";
|
|
7
|
-
import { cleanup } from "@testing-library/react";
|
|
8
|
-
import { afterEach } from "vitest";
|
|
9
|
-
|
|
10
|
-
// Cleanup after each test
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
cleanup();
|
|
13
|
-
});
|