All files / pages/api/lib/utils misc.ts

100% Statements 19/19
100% Branches 1/1
100% Functions 4/4
100% Lines 17/17

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 26 27 289x 9x     26x 26x 26x 26x 19x 19x   19x       7x     23x 23x 23x 23x 31x 31x   23x    
export default function isOnlySpaces(str: string): boolean {
  return str.trim().length === 0
}
 
export const parseGameTags = (gameTags: string[]): string => {
  const MAX_SHOWN = 3
  const gameTagsCopy = [...gameTags]
  if (gameTags.length > 3) {
    const totalTags = gameTags.length
    const restTags = totalTags - MAX_SHOWN
    gameTagsCopy.length = MAX_SHOWN // truncate array
    return `${gameTagsCopy
      .toLocaleString()
      .replace(/,/g, " • ")} • +${restTags} more`
  }
  return `${gameTagsCopy?.toLocaleString().replace(/,/g, " • ")}`
}
 
export const parseGameType = (gameType: string): string => {
  let res = ""
  const splittedStringCopy = [...gameType?.split("_")]
  splittedStringCopy.forEach((str: string) => {
    str.charAt(0).toUpperCase()
    res += `${str.charAt(0).toUpperCase()}${str.slice(1)} `
  })
  return res
}