Sawtaytoes
10/15/2018 - 12:35 AM

Other Simple Functions Unable to be Unit Tested

The in ability to unit test even the simplest of functions is a major problem when trying to refactor.

const colors = {
  orange: 'hue:43 saturation:1.0 brightness:1.0',
  orangeDark: 'hue:43 saturation:1.0 brightness:0.3',
  purple: 'hue:278 saturation:1.0 brightness:1.0',
  purpleDark: 'hue:278 saturation:1.0 brightness:0.3',
}

const colorSets = [{
  color: colors.orangeDark,
  from_color: colors.orange,
}, {
  color: colors.purpleDark,
  from_color: colors.purple,
}]

const getColorSetAtIndex = (
  index,
) => (
  colorSets[index]
)

const getRandomColorSetIndex = () => (
  Math.floor(
    Math.random() * colorSets.length
  )
)