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

Function expectTableToMatchContent

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

Source from the content-addressed store, hash-verified

3537}
3538
3539export function expectTableToMatchContent(tableElement: Element, expected: any[]) {
3540 const missedExpectations: string[] = [];
3541 function checkCellContent(actualCell: string, expectedCell: string) {
3542 if (actualCell !== expectedCell) {
3543 missedExpectations.push(`Expected cell contents to be ${expectedCell} but was ${actualCell}`);
3544 }
3545 }
3546
3547 const actual = getActualTableContent(tableElement);
3548
3549 // Make sure the number of rows match
3550 if (actual.length !== expected.length) {
3551 missedExpectations.push(`Expected ${expected.length} total rows but got ${actual.length}`);
3552 fail(missedExpectations.join('\n'));
3553 }
3554
3555 actual.forEach((row, rowIndex) => {
3556 const expectedRow = expected[rowIndex];
3557
3558 // Make sure the number of cells match
3559 if (row.length !== expectedRow.length) {
3560 missedExpectations.push(`Expected ${expectedRow.length} cells in row but got ${row.length}`);
3561 fail(missedExpectations.join('\n'));
3562 }
3563
3564 row.forEach((actualCell, cellIndex) => {
3565 const expectedCell = expectedRow ? expectedRow[cellIndex] : null;
3566 checkCellContent(actualCell, expectedCell);
3567 });
3568 });
3569
3570 if (missedExpectations.length) {
3571 fail(missedExpectations.join('\n'));
3572 }
3573}

Callers 2

table.spec.tsFile · 0.70

Calls 3

getActualTableContentFunction · 0.70
checkCellContentFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected