All files / organism/nestedCheckboxes/src settings.js

100% Statements 16/16
75% Branches 3/4
100% Functions 3/3
100% Lines 14/14

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 18 19 201x 1x 1x 1x   68x   13x   1x 22x 22x 22x 22x 22x 22x   22x    
export const BASE_CLASS = 'sui-OrganismNestedCheckboxes'
export const CONTAINER_CLASS = `${BASE_CLASS}Container`
export const CHILD_CLASS = `${BASE_CLASS}Child`
export const BUTTON_CLASS = `${BASE_CLASS}Button`
 
export const checkItemIsChecked = ({checked}) => checked === true
 
export const isFunction = fn => typeof fn === 'function'
 
export const getInnerCheckboxes = (node, {checked, indeterminate}) => {
  const checkboxes = Array.from(node.querySelectorAll("input[type='checkbox']"))
  let isChecked = checked
  let isIndeterminate = indeterminate
  Eif (checkboxes.length) {
    isChecked = checkboxes.every(checkItemIsChecked)
    isIndeterminate = !isChecked && checkboxes.some(checkItemIsChecked)
  }
  return [checkboxes, {checked: isChecked, indeterminate: isIndeterminate}]
}