Skip to content

Commit 115ce69

Browse files
committed
test(spec): type the carrier pins' stack fixtures through one loosely-typed build helper
Claude-Session: https://claude.ai/code/session_01Sfe5YjBLwB9J3y8fvm2xq1 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b4f2c59 commit 115ce69

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎packages/spec/src/inline-grid-column-carriers.test.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ const stackWithInlineColumns = (inlineColumns: unknown[]) => ({
103103
objects: [PARENT, childObject(inlineColumns)],
104104
});
105105

106+
/** `defineStack` over a fixture typed loosely on purpose — several are refused by design. */
107+
const build = (stack: unknown) => defineStack(stack as Parameters<typeof defineStack>[0]);
108+
106109
type Refusal = { code?: string; status?: number; issues?: unknown[]; message: string };
107110

108111
/** Run `defineStack` and return the refusal it threw — fails the test when it accepted. */
109112
function refusalOf(stack: unknown): Refusal {
110113
try {
111-
defineStack(stack as Parameters<typeof defineStack>[0]);
114+
build(stack);
112115
} catch (error) {
113116
return error as Refusal;
114117
}
@@ -129,7 +132,7 @@ function expectHydratedCurrencyRefusal(stack: unknown, location: string): void {
129132

130133
describe('#20901 — the form-view carrier references the column contract', () => {
131134
it('its column element IS InlineGridColumnSchema — one contract, not a copy', () => {
132-
const subforms = (FormViewSchema.shape as Record<string, { unwrap(): { element: { shape: Record<string, { unwrap(): { element: unknown } }> } } }>).subforms;
135+
const subforms = (FormViewSchema.shape as unknown as Record<string, { unwrap(): { element: { shape: Record<string, { unwrap(): { element: unknown } }> } } }>).subforms;
133136
const columnElement = subforms.unwrap().element.shape.columns.unwrap().element;
134137
expect(columnElement).toBe(InlineGridColumnSchema);
135138
});
@@ -219,21 +222,21 @@ describe('#20901 — defineStack judges an identity-only column by the type it r
219222
{ name: 'amount', type: 'number', scale: 2 },
220223
{ name: 'not_a_child_field', scale: 2 },
221224
];
222-
expect(() => defineStack(stackWithSubformColumns(columns) as Parameters<typeof defineStack>[0])).not.toThrow();
223-
expect(() => defineStack(stackWithSubformColumns(columns, 'formViews') as Parameters<typeof defineStack>[0])).not.toThrow();
224-
expect(() => defineStack(stackWithInlineColumns(columns) as Parameters<typeof defineStack>[0])).not.toThrow();
225+
expect(() => build(stackWithSubformColumns(columns))).not.toThrow();
226+
expect(() => build(stackWithSubformColumns(columns, 'formViews'))).not.toThrow();
227+
expect(() => build(stackWithInlineColumns(columns))).not.toThrow();
225228
});
226229

227230
it('CONTROL — a child object this stack does not declare is not judged: an unresolved column is not a wrong one', () => {
228231
const stack = stackWithSubformColumns([IDENTITY_ONLY_WITH_SCALE], 'form', 'ext_line');
229-
expect(() => defineStack(stack as Parameters<typeof defineStack>[0])).not.toThrow();
232+
expect(() => build(stack)).not.toThrow();
230233
});
231234

232235
it('following the remedy builds: the refused column with `scale` deleted and nothing added', () => {
233236
const remedied: Record<string, unknown> = { ...IDENTITY_ONLY_WITH_SCALE };
234237
delete remedied.scale;
235238
expect(Object.keys(remedied)).toEqual(['name']);
236-
expect(() => defineStack(stackWithSubformColumns([remedied]) as Parameters<typeof defineStack>[0])).not.toThrow();
237-
expect(() => defineStack(stackWithInlineColumns([remedied]) as Parameters<typeof defineStack>[0])).not.toThrow();
239+
expect(() => build(stackWithSubformColumns([remedied]))).not.toThrow();
240+
expect(() => build(stackWithInlineColumns([remedied]))).not.toThrow();
238241
});
239242
});

0 commit comments

Comments
 (0)