Skip to content

Commit da88f3e

Browse files
committed
style(layout-tests): apply biome formatting and import ordering
Fix lint failures in CI by formatting newly added layout test suites and normalizing import ordering.
1 parent dab35a2 commit da88f3e

7 files changed

Lines changed: 124 additions & 105 deletions

packages/core/src/layout/__tests__/layout.aspect-ratio.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import type { LayoutTree } from "../layout.js";
44
import { layout } from "../layout.js";
55
import type { Axis } from "../types.js";
66

7-
function mustLayout(
8-
node: VNode,
9-
maxW: number,
10-
maxH: number,
11-
axis: Axis = "column",
12-
): LayoutTree {
7+
function mustLayout(node: VNode, maxW: number, maxH: number, axis: Axis = "column"): LayoutTree {
138
const res = layout(node, 0, 0, maxW, maxH, axis);
149
assert.equal(res.ok, true, "layout should succeed");
1510
if (!res.ok) {
@@ -59,7 +54,7 @@ describe("layout aspect-ratio (deterministic)", () => {
5954
assert.deepEqual(out.rect, { x: 0, y: 0, w: 7, h: 3 });
6055
});
6156

62-
test('percent width with aspectRatio resolves against parent width', () => {
57+
test("percent width with aspectRatio resolves against parent width", () => {
6358
const node: VNode = {
6459
kind: "box",
6560
props: { border: "none", width: "50%", aspectRatio: 2 },
@@ -69,7 +64,7 @@ describe("layout aspect-ratio (deterministic)", () => {
6964
assert.deepEqual(out.rect, { x: 0, y: 0, w: 7, h: 3 });
7065
});
7166

72-
test('percent height with aspectRatio resolves against parent height', () => {
67+
test("percent height with aspectRatio resolves against parent height", () => {
7368
const node: VNode = {
7469
kind: "box",
7570
props: { border: "none", height: "25%", aspectRatio: 2 },
@@ -124,7 +119,11 @@ describe("layout aspect-ratio (deterministic)", () => {
124119
kind: "row",
125120
props: {},
126121
children: Object.freeze([
127-
{ kind: "box", props: { border: "none", height: 4, aspectRatio: 2 }, children: Object.freeze([]) },
122+
{
123+
kind: "box",
124+
props: { border: "none", height: 4, aspectRatio: 2 },
125+
children: Object.freeze([]),
126+
},
128127
{ kind: "box", props: { border: "none", flex: 1 }, children: Object.freeze([]) },
129128
]),
130129
};
@@ -139,7 +138,11 @@ describe("layout aspect-ratio (deterministic)", () => {
139138
kind: "column",
140139
props: {},
141140
children: Object.freeze([
142-
{ kind: "box", props: { border: "none", width: 6, aspectRatio: 2 }, children: Object.freeze([]) },
141+
{
142+
kind: "box",
143+
props: { border: "none", width: 6, aspectRatio: 2 },
144+
children: Object.freeze([]),
145+
},
143146
{ kind: "box", props: { border: "none", flex: 1 }, children: Object.freeze([]) },
144147
]),
145148
};

packages/core/src/layout/__tests__/layout.auto-sizing.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const CASES: readonly AutoCase[] = [
5959
expectedChildren: [{ x: 0, y: 0, w: 5, h: 1 }],
6060
},
6161
{
62-
name: 'auto box includes padding in intrinsic size',
62+
name: "auto box includes padding in intrinsic size",
6363
vnode: ui.box({ border: "none", width: "auto", height: "auto", p: 2 }, [ui.text("hello")]),
6464
axis: "column",
6565
maxW: 50,
@@ -68,7 +68,7 @@ const CASES: readonly AutoCase[] = [
6868
expectedChildren: [{ x: 2, y: 2, w: 5, h: 1 }],
6969
},
7070
{
71-
name: 'row auto child without flex does not join flex distribution',
71+
name: "row auto child without flex does not join flex distribution",
7272
vnode: ui.row({ width: 20, height: 4, gap: 1 }, [
7373
ui.box({ border: "none", width: "auto" }, [ui.text("abcd")]),
7474
ui.box({ border: "none", flex: 1 }, []),
@@ -132,7 +132,7 @@ const CASES: readonly AutoCase[] = [
132132
expectedChild0Children: [{ x: 0, y: 0, w: 2, h: 1 }],
133133
},
134134
{
135-
name: 'column auto child without flex does not join flex distribution',
135+
name: "column auto child without flex does not join flex distribution",
136136
vnode: ui.column({ width: 12, height: 12, gap: 1 }, [
137137
ui.box({ border: "none", height: "auto" }, [ui.text("x")]),
138138
ui.box({ border: "none", flex: 1 }, []),

packages/core/src/layout/__tests__/layout.flex-distribution.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ const CASES: readonly FlexCase[] = [
288288
name: "total flex is zero and oversized fixed children clamp without negatives",
289289
main: 5,
290290
cross: 5,
291-
children: [{ main: 6, flex: 0 }, { main: 6, flex: 0 }],
291+
children: [
292+
{ main: 6, flex: 0 },
293+
{ main: 6, flex: 0 },
294+
],
292295
expectedRowChildren: [
293296
{ x: 0, y: 0, w: 5, h: 0 },
294297
{ x: 5, y: 0, w: 0, h: 0 },

packages/core/src/layout/__tests__/layout.margin.test.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ function mustMeasure(node: VNode, maxW: number, maxH: number, axis: Axis = "colu
1313
return res.value;
1414
}
1515

16-
function mustLayout(
17-
node: VNode,
18-
maxW: number,
19-
maxH: number,
20-
axis: Axis = "column",
21-
): LayoutTree {
16+
function mustLayout(node: VNode, maxW: number, maxH: number, axis: Axis = "column"): LayoutTree {
2217
const res = layout(node, 0, 0, maxW, maxH, axis);
2318
assert.equal(res.ok, true, "layout should succeed");
2419
if (!res.ok) {
@@ -92,7 +87,11 @@ describe("layout margin (deterministic)", () => {
9287
props: { border: "none", width: 1, height: 1, ml: -2, mr: -2, mt: -1, mb: -1 },
9388
children: Object.freeze([]),
9489
},
95-
{ kind: "box", props: { border: "none", width: 2, height: 1 }, children: Object.freeze([]) },
90+
{
91+
kind: "box",
92+
props: { border: "none", width: 2, height: 1 },
93+
children: Object.freeze([]),
94+
},
9695
]),
9796
};
9897
const out = mustLayout(row, 5, 2, "row");
@@ -111,7 +110,11 @@ describe("layout margin (deterministic)", () => {
111110
props: { border: "none", width: 2, height: 1, ml: -1, mr: -1, mt: -2, mb: -1 },
112111
children: Object.freeze([]),
113112
},
114-
{ kind: "box", props: { border: "none", width: 1, height: 1 }, children: Object.freeze([]) },
113+
{
114+
kind: "box",
115+
props: { border: "none", width: 1, height: 1 },
116+
children: Object.freeze([]),
117+
},
115118
]),
116119
};
117120
const out = mustLayout(column, 4, 3, "column");
@@ -125,7 +128,11 @@ describe("layout margin (deterministic)", () => {
125128
kind: "row",
126129
props: { p: 1 },
127130
children: Object.freeze([
128-
{ kind: "box", props: { border: "none", width: 2, height: 1, m: 1 }, children: Object.freeze([]) },
131+
{
132+
kind: "box",
133+
props: { border: "none", width: 2, height: 1, m: 1 },
134+
children: Object.freeze([]),
135+
},
129136
]),
130137
};
131138
const out = mustLayout(row, 20, 10, "row");
@@ -202,7 +209,18 @@ describe("layout margin (deterministic)", () => {
202209
test("per-side margins override mx/my/m in layout", () => {
203210
const box: VNode = {
204211
kind: "box",
205-
props: { border: "none", width: 4, height: 2, m: 1, mx: 2, my: 3, mt: 4, mr: 5, mb: 6, ml: 7 },
212+
props: {
213+
border: "none",
214+
width: 4,
215+
height: 2,
216+
m: 1,
217+
mx: 2,
218+
my: 3,
219+
mt: 4,
220+
mr: 5,
221+
mb: 6,
222+
ml: 7,
223+
},
206224
children: Object.freeze([]),
207225
};
208226
const size = mustMeasure(box, 40, 40);

packages/core/src/layout/__tests__/layout.percentage.test.ts

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const ROW_CASES: readonly PercentageCase[] = [
3636
},
3737
{
3838
name: 'row main-axis "0%" yields zero-width sibling',
39-
vnode: ui.row(
40-
{ width: 20, height: 6 },
41-
[ui.box({ border: "none", width: "0%" }, []), ui.box({ border: "none", width: 4 }, [])],
42-
),
39+
vnode: ui.row({ width: 20, height: 6 }, [
40+
ui.box({ border: "none", width: "0%" }, []),
41+
ui.box({ border: "none", width: 4 }, []),
42+
]),
4343
maxW: 20,
4444
maxH: 6,
4545
axis: "row",
@@ -60,10 +60,10 @@ const ROW_CASES: readonly PercentageCase[] = [
6060
},
6161
{
6262
name: 'row "150%" first child can starve later fixed sibling',
63-
vnode: ui.row(
64-
{ width: 20, height: 6 },
65-
[ui.box({ border: "none", width: "150%" }, []), ui.box({ border: "none", width: 3 }, [])],
66-
),
63+
vnode: ui.row({ width: 20, height: 6 }, [
64+
ui.box({ border: "none", width: "150%" }, []),
65+
ui.box({ border: "none", width: 3 }, []),
66+
]),
6767
maxW: 20,
6868
maxH: 6,
6969
axis: "row",
@@ -76,7 +76,9 @@ const ROW_CASES: readonly PercentageCase[] = [
7676
{
7777
name: "row nested percentages 50% -> 50% resolve recursively",
7878
vnode: ui.row({ width: 40, height: 8 }, [
79-
ui.box({ border: "none", width: "50%" }, [ui.box({ border: "none", width: "50%" }, [ui.text("x")])]),
79+
ui.box({ border: "none", width: "50%" }, [
80+
ui.box({ border: "none", width: "50%" }, [ui.text("x")]),
81+
]),
8082
]),
8183
maxW: 40,
8284
maxH: 8,
@@ -88,10 +90,9 @@ const ROW_CASES: readonly PercentageCase[] = [
8890
{
8991
name: "row nested 100% parent + 150% child clamps at parent content",
9092
vnode: ui.row({ width: 20, height: 8 }, [
91-
ui.box(
92-
{ border: "none", width: "100%" },
93-
[ui.box({ border: "none", width: "150%" }, [ui.text("x")])],
94-
),
93+
ui.box({ border: "none", width: "100%" }, [
94+
ui.box({ border: "none", width: "150%" }, [ui.text("x")]),
95+
]),
9596
]),
9697
maxW: 20,
9798
maxH: 8,
@@ -111,7 +112,9 @@ const ROW_CASES: readonly PercentageCase[] = [
111112
},
112113
{
113114
name: 'row cross-axis "0%" height resolves to zero',
114-
vnode: ui.row({ width: 20, height: 10 }, [ui.box({ border: "none", width: 4, height: "0%" }, [])]),
115+
vnode: ui.row({ width: 20, height: 10 }, [
116+
ui.box({ border: "none", width: 4, height: "0%" }, []),
117+
]),
115118
maxW: 20,
116119
maxH: 10,
117120
axis: "row",
@@ -120,7 +123,9 @@ const ROW_CASES: readonly PercentageCase[] = [
120123
},
121124
{
122125
name: 'row cross-axis "150%" height clamps to container height',
123-
vnode: ui.row({ width: 20, height: 10 }, [ui.box({ border: "none", width: 4, height: "150%" }, [])]),
126+
vnode: ui.row({ width: 20, height: 10 }, [
127+
ui.box({ border: "none", width: 4, height: "150%" }, []),
128+
]),
124129
maxW: 20,
125130
maxH: 10,
126131
axis: "row",
@@ -129,10 +134,10 @@ const ROW_CASES: readonly PercentageCase[] = [
129134
},
130135
{
131136
name: "row percentage sizing subtracts total gap before allocation",
132-
vnode: ui.row(
133-
{ width: 21, height: 5, gap: 2 },
134-
[ui.box({ border: "none", width: "50%" }, []), ui.box({ border: "none", width: "50%" }, [])],
135-
),
137+
vnode: ui.row({ width: 21, height: 5, gap: 2 }, [
138+
ui.box({ border: "none", width: "50%" }, []),
139+
ui.box({ border: "none", width: "50%" }, []),
140+
]),
136141
maxW: 21,
137142
maxH: 5,
138143
axis: "row",
@@ -175,10 +180,10 @@ const COLUMN_CASES: readonly PercentageCase[] = [
175180
},
176181
{
177182
name: 'column main-axis "0%" yields zero-height sibling',
178-
vnode: ui.column(
179-
{ height: 20, width: 6 },
180-
[ui.box({ border: "none", height: "0%" }, []), ui.box({ border: "none", height: 4 }, [])],
181-
),
183+
vnode: ui.column({ height: 20, width: 6 }, [
184+
ui.box({ border: "none", height: "0%" }, []),
185+
ui.box({ border: "none", height: 4 }, []),
186+
]),
182187
maxW: 6,
183188
maxH: 20,
184189
axis: "column",
@@ -199,10 +204,10 @@ const COLUMN_CASES: readonly PercentageCase[] = [
199204
},
200205
{
201206
name: 'column "150%" first child can starve later fixed sibling',
202-
vnode: ui.column(
203-
{ height: 20, width: 6 },
204-
[ui.box({ border: "none", height: "150%" }, []), ui.box({ border: "none", height: 3 }, [])],
205-
),
207+
vnode: ui.column({ height: 20, width: 6 }, [
208+
ui.box({ border: "none", height: "150%" }, []),
209+
ui.box({ border: "none", height: 3 }, []),
210+
]),
206211
maxW: 6,
207212
maxH: 20,
208213
axis: "column",
@@ -215,10 +220,9 @@ const COLUMN_CASES: readonly PercentageCase[] = [
215220
{
216221
name: "column nested percentages 50% -> 50% resolve recursively",
217222
vnode: ui.column({ height: 40, width: 8 }, [
218-
ui.box(
219-
{ border: "none", height: "50%" },
220-
[ui.box({ border: "none", height: "50%" }, [ui.text("x")])],
221-
),
223+
ui.box({ border: "none", height: "50%" }, [
224+
ui.box({ border: "none", height: "50%" }, [ui.text("x")]),
225+
]),
222226
]),
223227
maxW: 8,
224228
maxH: 40,
@@ -230,10 +234,9 @@ const COLUMN_CASES: readonly PercentageCase[] = [
230234
{
231235
name: "column nested 100% parent + 150% child clamps at parent content",
232236
vnode: ui.column({ height: 20, width: 8 }, [
233-
ui.box(
234-
{ border: "none", height: "100%" },
235-
[ui.box({ border: "none", height: "150%" }, [ui.text("x")])],
236-
),
237+
ui.box({ border: "none", height: "100%" }, [
238+
ui.box({ border: "none", height: "150%" }, [ui.text("x")]),
239+
]),
237240
]),
238241
maxW: 8,
239242
maxH: 20,
@@ -253,7 +256,9 @@ const COLUMN_CASES: readonly PercentageCase[] = [
253256
},
254257
{
255258
name: 'column cross-axis "0%" width resolves to zero',
256-
vnode: ui.column({ height: 20, width: 10 }, [ui.box({ border: "none", height: 4, width: "0%" }, [])]),
259+
vnode: ui.column({ height: 20, width: 10 }, [
260+
ui.box({ border: "none", height: 4, width: "0%" }, []),
261+
]),
257262
maxW: 10,
258263
maxH: 20,
259264
axis: "column",
@@ -262,7 +267,9 @@ const COLUMN_CASES: readonly PercentageCase[] = [
262267
},
263268
{
264269
name: 'column cross-axis "150%" width clamps to container width',
265-
vnode: ui.column({ height: 20, width: 10 }, [ui.box({ border: "none", height: 4, width: "150%" }, [])]),
270+
vnode: ui.column({ height: 20, width: 10 }, [
271+
ui.box({ border: "none", height: 4, width: "150%" }, []),
272+
]),
266273
maxW: 10,
267274
maxH: 20,
268275
axis: "column",
@@ -271,10 +278,10 @@ const COLUMN_CASES: readonly PercentageCase[] = [
271278
},
272279
{
273280
name: "column percentage sizing subtracts total gap before allocation",
274-
vnode: ui.column(
275-
{ height: 21, width: 5, gap: 2 },
276-
[ui.box({ border: "none", height: "50%" }, []), ui.box({ border: "none", height: "50%" }, [])],
277-
),
281+
vnode: ui.column({ height: 21, width: 5, gap: 2 }, [
282+
ui.box({ border: "none", height: "50%" }, []),
283+
ui.box({ border: "none", height: "50%" }, []),
284+
]),
278285
maxW: 5,
279286
maxH: 21,
280287
axis: "column",

0 commit comments

Comments
 (0)