MCPcopy Index your code
hub / github.com/TanStack/table / createTestTable

Function createTestTable

packages/angular-table/tests/flex-render-table.test.ts:355–473  ·  view source on GitHub ↗
(
  data: TestData[],
  columns: ColumnDef<TestData, any>[],
  optionsFn?: () => Partial<TableOptions<TestData>>,
)

Source from the content-addressed store, hash-verified

353type TestData = { id: string; title: string }
354
355export function createTestTable(
356 data: TestData[],
357 columns: ColumnDef<TestData, any>[],
358 optionsFn?: () => Partial<TableOptions<TestData>>,
359) {
360 @Component({
361 template: `
362 <table>
363 <thead data-testid="thead">
364 @for (headerGroup of table.getHeaderGroups(); track headerGroup.id) {
365 <tr
366 data-testid="thead_row"
367 [attr.data-testid]="'thead_headergroup_' + headerGroup.id"
368 >
369 @for (header of headerGroup.headers; track header.id) {
370 @if (!header.isPlaceholder) {
371 <th
372 [attr.data-testid]="
373 'thead_headergroup_' + headerGroup.id + '_' + header.id
374 "
375 >
376 <ng-container
377 *flexRender="
378 header.column.columnDef.header;
379 props: header.getContext();
380 let header
381 "
382 >
383 <span [innerHTML]="header"></span>
384 </ng-container>
385 </th>
386 }
387 }
388 </tr>
389 }
390 </thead>
391 <tbody>
392 @for (row of table.getRowModel().rows; track row.id) {
393 <tr [attr.data-testid]="'row_' + row.id">
394 @for (cell of row.getVisibleCells(); track cell.id) {
395 <td [attr.data-testid]="'row_' + row.id + '_cell_' + cell.id">
396 <ng-container
397 *flexRender="
398 cell.column.columnDef.cell;
399 props: cell.getContext();
400 let cell
401 "
402 >
403 <span [innerHTML]="cell"></span>
404 </ng-container>
405 </td>
406 }
407 </tr>
408 }
409 </tbody>
410 </table>
411
412 <button (click)="(0)">Trigger CD</button>

Callers 1

Calls 1

createComponentMethod · 0.80

Tested by

no test coverage detected