All files / server/src/utils isStartTimeMatch.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 1/1
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 23 24 25      59x         20911x   20911x   20911x 6484x     14427x   14427x       14427x    
import dayjs from "dayjs";
import { config } from "shared/config";
 
export const isStartTimeMatch = (
  startTime: string,
  timeToMatch: string,
  parentId: string | undefined,
): boolean => {
  const { startTimesByParentIds } = config.event();
 
  const startTimeMatch = dayjs(startTime).isSame(dayjs(timeToMatch), "minute");
 
  if (!parentId) {
    return startTimeMatch;
  }
 
  const parentIdMatch = startTimesByParentIds.has(parentId);
 
  const parentStartTimeMatch = dayjs(
    startTimesByParentIds.get(parentId),
  ).isSame(timeToMatch, "minute");
 
  return parentIdMatch ? parentStartTimeMatch : startTimeMatch;
};