Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function populateAncestorTitlesRecursive(
node: ParsedNodeWithAncestorTitles,
ancestorTitles: string[],
itBlocksWithAncestorTitles: ItBlockWithAncestorTitles[]
) {
node.ancestorTitles = ancestorTitles;
if (node.type === ParsedNodeTypes.it) {
itBlocksWithAncestorTitles.push(node as ItBlockWithAncestorTitles);
}
if (
node.type === ParsedNodeTypes.root ||
node.type === ParsedNodeTypes.describe
) {
if (!node.children) {
return;
}
node.children.forEach(childNode => {
populateAncestorTitlesRecursive(
childNode,
node.name ? [...ancestorTitles, node.name] : ancestorTitles,
itBlocksWithAncestorTitles
);
});
}
}