All files / app/assets/javascripts/vue_shared/components/sidebar/todo_toggle utils.js

100% Statements 9/9
100% Branches 4/4
100% Functions 2/2
100% Lines 8/8

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 20 21 22    16x 36x     16x 9x   9x   7x   7x           7x    
import { __ } from '~/locale';
 
export const todoLabel = (hasTodo) => {
  return hasTodo ? __('Mark as done') : __('Add a to do');
};
 
export const updateGlobalTodoCount = (additionalTodoCount) => {
  const countContainer = document.querySelector('.js-todos-count');
 
  if (countContainer === null) return;
 
  const currentCount = parseInt(countContainer.innerText, 10);
 
  const todoToggleEvent = new CustomEvent('todo:toggle', {
    detail: {
      count: Math.max(currentCount + additionalTodoCount, 0),
    },
  });
 
  document.dispatchEvent(todoToggleEvent);
};