@window-splitter/state 0.2.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.
- package/.tshy/build.json +8 -0
- package/.tshy/commonjs.json +17 -0
- package/.tshy/esm.json +16 -0
- package/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-lint.log +5 -0
- package/.turbo/turbo-test.log +278 -0
- package/CHANGELOG.md +191 -0
- package/README.md +13 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +350 -0
- package/coverage/coverage-final.json +2 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +116 -0
- package/coverage/index.ts.html +4627 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/commonjs/index.d.ts +314 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +932 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/machine.test.d.ts +5 -0
- package/dist/commonjs/machine.test.d.ts.map +1 -0
- package/dist/commonjs/machine.test.js +1038 -0
- package/dist/commonjs/machine.test.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/utils.test.d.ts +2 -0
- package/dist/commonjs/utils.test.d.ts.map +1 -0
- package/dist/commonjs/utils.test.js +79 -0
- package/dist/commonjs/utils.test.js.map +1 -0
- package/dist/esm/index.d.ts +314 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +890 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/machine.test.d.ts +5 -0
- package/dist/esm/machine.test.d.ts.map +1 -0
- package/dist/esm/machine.test.js +1036 -0
- package/dist/esm/machine.test.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/utils.test.d.ts +2 -0
- package/dist/esm/utils.test.d.ts.map +1 -0
- package/dist/esm/utils.test.js +77 -0
- package/dist/esm/utils.test.js.map +1 -0
- package/eslint.config.js +3 -0
- package/package.json +79 -0
- package/src/index.ts +1514 -0
- package/src/machine.test.ts +1316 -0
- package/src/utils.test.ts +104 -0
- package/tsconfig.json +3 -0
- package/vitest.config.ts +16 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { expect, test, describe } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getUnitPercentageValue,
|
|
5
|
+
getCollapsiblePanelForHandleId,
|
|
6
|
+
groupMachine,
|
|
7
|
+
initializePanel,
|
|
8
|
+
} from "./index.js";
|
|
9
|
+
import { createActor } from "xstate";
|
|
10
|
+
|
|
11
|
+
describe("getUnitPercentageValue", () => {
|
|
12
|
+
test("works with pixels", () => {
|
|
13
|
+
expect(getUnitPercentageValue(100, { type: "pixel", value: 100 })).toBe(1);
|
|
14
|
+
expect(getUnitPercentageValue(100, { type: "pixel", value: 50 })).toBe(0.5);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("works with percentages", () => {
|
|
18
|
+
expect(getUnitPercentageValue(100, { type: "percent", value: 1 })).toBe(1);
|
|
19
|
+
expect(getUnitPercentageValue(100, { type: "percent", value: 0.5 })).toBe(
|
|
20
|
+
0.5
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("getCollapsiblePanelForHandleId", () => {
|
|
26
|
+
test("works with left collapsible panel", () => {
|
|
27
|
+
const actor = createActor(groupMachine, {
|
|
28
|
+
input: {
|
|
29
|
+
groupId: "group",
|
|
30
|
+
initialItems: [
|
|
31
|
+
initializePanel({ id: "panel-1", collapsible: true }),
|
|
32
|
+
{
|
|
33
|
+
type: "handle",
|
|
34
|
+
id: "resizer-1",
|
|
35
|
+
size: { type: "pixel", value: 10 },
|
|
36
|
+
},
|
|
37
|
+
initializePanel({ id: "panel-2" }),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
}).start();
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
getCollapsiblePanelForHandleId(actor.getSnapshot().context, "resizer-1")
|
|
44
|
+
?.id
|
|
45
|
+
).toBe("panel-1");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("works with right collapsible panel", () => {
|
|
49
|
+
const actor = createActor(groupMachine, {
|
|
50
|
+
input: {
|
|
51
|
+
groupId: "group",
|
|
52
|
+
initialItems: [
|
|
53
|
+
initializePanel({ id: "panel-1" }),
|
|
54
|
+
{
|
|
55
|
+
type: "handle",
|
|
56
|
+
id: "resizer-1",
|
|
57
|
+
size: { type: "pixel", value: 10 },
|
|
58
|
+
},
|
|
59
|
+
initializePanel({ id: "panel-2", collapsible: true }),
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
}).start();
|
|
63
|
+
|
|
64
|
+
expect(
|
|
65
|
+
getCollapsiblePanelForHandleId(actor.getSnapshot().context, "resizer-1")
|
|
66
|
+
?.id
|
|
67
|
+
).toBe("panel-2");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("throws when no items", () => {
|
|
71
|
+
const actor = createActor(groupMachine, {
|
|
72
|
+
input: {
|
|
73
|
+
groupId: "group",
|
|
74
|
+
initialItems: [],
|
|
75
|
+
},
|
|
76
|
+
}).start();
|
|
77
|
+
|
|
78
|
+
expect(() =>
|
|
79
|
+
getCollapsiblePanelForHandleId(actor.getSnapshot().context, "resizer-1")
|
|
80
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: No items in group]`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("throws when no collapsible panel", () => {
|
|
84
|
+
const actor = createActor(groupMachine, {
|
|
85
|
+
input: {
|
|
86
|
+
groupId: "group",
|
|
87
|
+
initialItems: [
|
|
88
|
+
initializePanel({ id: "panel-1" }),
|
|
89
|
+
{
|
|
90
|
+
type: "handle",
|
|
91
|
+
id: "resizer-1",
|
|
92
|
+
size: { type: "pixel", value: 10 },
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
}).start();
|
|
97
|
+
|
|
98
|
+
expect(() =>
|
|
99
|
+
getCollapsiblePanelForHandleId(actor.getSnapshot().context, "resizer-1")
|
|
100
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
101
|
+
`[Error: No collapsible panel found for handle: resizer-1]`
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
package/tsconfig.json
ADDED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
coverage: {
|
|
6
|
+
provider: "istanbul",
|
|
7
|
+
},
|
|
8
|
+
browser: {
|
|
9
|
+
enabled: true,
|
|
10
|
+
name: "chromium",
|
|
11
|
+
provider: "playwright",
|
|
12
|
+
// https://playwright.dev
|
|
13
|
+
providerOptions: {},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|