All files / actions init.ts

50% Statements 5/10
100% Branches 0/0
33.33% Functions 1/3
50% Lines 5/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181x   1x 1x 1x   1x                      
import { getSiblings } from '../lib/get-siblings-of-element'
 
export const init = (menuItemClass: string, overrideMenuClass: string) => {
  const menuItems = document.querySelectorAll(`[class^=${menuItemClass}]`)
  console.log('TCL: init -> menuItems', menuItems)
 
  menuItems.forEach((menuItem: HTMLElement) => {
    const parent = menuItem.parentElement
    const siblings = getSiblings(parent)
 
    const respectiveDropdown = siblings.find((el: HTMLElement) => {
      return el.className === overrideMenuClass
    })
 
    respectiveDropdown.style.display = 'none'
  })
}