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

Function expectTableToMatchContent

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

Source from the content-addressed store, hash-verified

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

Callers 1

table.spec.tsFile · 0.70

Calls 3

getActualTableContentFunction · 0.70
checkCellContentFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected