All files / components/Utils HomePageBackground.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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 28 29 30 31 32 33 34 35                                                                     
import BackgroundDay from './../../../assets/HomePageBackground-day.png';
import BackgroundEvening from './../../../assets/HomePageBackground-evening.png';
import BackgroundMorning from './../../../assets/HomePageBackground-morning.png';
import BackgroundNight from './../../../assets/HomePageBackground-night.png';
 
//LP-adding lower resolution images JPG format
import BackgroundDay_LowRes from './../../../assets/HomePageBackground-day.jpg';
import BackgroundEvening_LowRes from './../../../assets/HomePageBackground-evening.jpg';
import BackgroundMorning_LowRes from './../../../assets/HomePageBackground-morning.jpg';
import BackgroundNight_LowRes from './../../../assets/HomePageBackground-night.jpg';
 
// istanbul ignore next: trivial function to ignore from coverage due to how it is structured. Should be refactored in the future so that it can be tested.
export default function getBackgroundImage(time, res) {
  if( res === 1 ) { //1 corresponds to higher res 
      if (time >= 6 && time < 9) {
        return BackgroundMorning;
      } else if (time >= 9 && time < 18) {
        return BackgroundDay;
      } else if (time >= 18 && time < 21) {
        return BackgroundEvening;
      } else {
        return BackgroundNight;
      }
    } else { 
      if (time >= 6 && time < 9) {
        return BackgroundMorning_LowRes;
      } else if (time >= 9 && time < 18) {
        return BackgroundDay_LowRes;
      } else if (time >= 18 && time < 21) {
        return BackgroundEvening_LowRes;
      } else {
        return BackgroundNight_LowRes;
      }
    }
}