MCPcopy Create free account
hub / github.com/angular/components / expectTableToMatchContent

Function expectTableToMatchContent

src/cdk/table/table.spec.ts:3596–3630  ·  view source on GitHub ↗
(tableElement: Element, expected: any[])

Source from the content-addressed store, hash-verified

3594}
3595
3596export function expectTableToMatchContent(tableElement: Element, expected: any[]) {
3597 const missedExpectations: string[] = [];
3598 function checkCellContent(actualCell: string, expectedCell: string) {
3599 if (actualCell !== expectedCell) {
3600 missedExpectations.push(`Expected cell contents to be ${expectedCell} but was ${actualCell}`);
3601 }
3602 }
3603
3604 const actual = getActualTableContent(tableElement);
3605
3606 // Make sure the number of rows match
3607 if (actual.length !== expected.length) {
3608 missedExpectations.push(`Expected ${expected.length} total rows but got ${actual.length}`);
3609 fail(missedExpectations.join('\n'));
3610 }
3611
3612 actual.forEach((row, rowIndex) => {
3613 const expectedRow = expected[rowIndex];
3614
3615 // Make sure the number of cells match
3616 if (row.length !== expectedRow.length) {
3617 missedExpectations.push(`Expected ${expectedRow.length} cells in row but got ${row.length}`);
3618 fail(missedExpectations.join('\n'));
3619 }
3620
3621 row.forEach((actualCell, cellIndex) => {
3622 const expectedCell = expectedRow ? expectedRow[cellIndex] : null;
3623 checkCellContent(actualCell, expectedCell);
3624 });
3625 });
3626
3627 if (missedExpectations.length) {
3628 fail(missedExpectations.join('\n'));
3629 }
3630}

Callers 2

table.spec.tsFile · 0.70

Calls 3

getActualTableContentFunction · 0.70
checkCellContentFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected