Skip to content

Commit 9bf3040

Browse files
committed
Test setting columnLabels in spreadsheet
1 parent 25033a2 commit 9bf3040

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Spreadsheet.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@ describe("<Spreadsheet />", () => {
235235
);
236236
expect(rowLabels).toEqual(EXAMPLE_ROW_LABELS);
237237
});
238+
test("setting column labels changes colum indicators labels", () => {
239+
const EXAMPLE_COLUMN_LABELS = ["First", "Second", "Third", "Fourth"];
240+
render(
241+
<Spreadsheet {...EXAMPLE_PROPS} columnLabels={EXAMPLE_COLUMN_LABELS} />
242+
);
243+
const element = getSpreadsheetElement();
244+
// Get column label elements.
245+
// Select from first row as it holds all the column indicators
246+
// Do not select first child as it is corner indicator
247+
const columnLabelElements = element.querySelectorAll(
248+
"tr:first-child th:not(:first-child)"
249+
);
250+
const columnLabels = Array.from(
251+
columnLabelElements,
252+
(element) => element.textContent
253+
);
254+
expect(columnLabels).toEqual(EXAMPLE_COLUMN_LABELS);
255+
});
238256
});
239257

240258
/** Like .querySelector() but throws for no match */

0 commit comments

Comments
 (0)