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

Function expectTableToMatchContent

src/material/table/table.spec.ts:1115–1149  ·  view source on GitHub ↗
(tableElement: Element, expected: string[][])

Source from the content-addressed store, hash-verified

1113}
1114
1115export function expectTableToMatchContent(tableElement: Element, expected: string[][]) {
1116 const missedExpectations: string[] = [];
1117 function checkCellContent(actualCell: string, expectedCell: string) {
1118 if (actualCell !== expectedCell) {
1119 missedExpectations.push(`Expected cell contents to be ${expectedCell} but was ${actualCell}`);
1120 }
1121 }
1122
1123 const actual = getActualTableContent(tableElement);
1124
1125 // Make sure the number of rows match
1126 if (actual.length !== expected.length) {
1127 missedExpectations.push(`Expected ${expected.length} total rows but got ${actual.length}`);
1128 fail(missedExpectations.join('\n'));
1129 }
1130
1131 actual.forEach((row, rowIndex) => {
1132 const expectedRow = expected[rowIndex];
1133
1134 // Make sure the number of cells match
1135 if (row.length !== expectedRow.length) {
1136 missedExpectations.push(`Expected ${expectedRow.length} cells in row but got ${row.length}`);
1137 fail(missedExpectations.join('\n'));
1138 }
1139
1140 row.forEach((actualCell, cellIndex) => {
1141 const expectedCell = expectedRow[cellIndex];
1142 checkCellContent(actualCell, expectedCell);
1143 });
1144 });
1145
1146 if (missedExpectations.length) {
1147 fail(missedExpectations.join('\n'));
1148 }
1149}

Callers 1

table.spec.tsFile · 0.70

Calls 3

getActualTableContentFunction · 0.70
checkCellContentFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected