Hey there, I'm facing an issue with my test and I can't figure out how to solve it. I'm using Jasmine with Angular.
In a directive, I need to access the parentNode of an element but the test keeps failing. Does anyone have any suggestions on how to mock this?
https://i.sstatic.net/D5J2W.png
Here's the code snippet:
private getParentElement() {
return this.element.nativeElement.closest('th');
}
private setActiveSortingCellOnLoad(): void {
const selectors = "[name='arrows-sort-down'] , [name='arrows-sort-up']";
const headerCells = this.getParentElement().parentElement.childNodes;
headerCells.forEach(cell => {
if (cell.childNodes.length > 0) {
const el = cell.querySelectorAll(selectors);
if (el.length === 1) {
cell.classList.add(this.activeSortClass);
}
}
});
}