All files / pages HomePage.js

100% Statements 12/12
100% Branches 8/8
100% Functions 2/2
100% Lines 10/10

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 36 37 38 39 40 41 42              24x   24x 24x 24x 16x 4x     24x   24x 15x                       9x                    
import React from "react";
import { useCurrentUser } from "main/utils/currentUser"; 
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
 
 
export default function HomePage() {
 
    const { data: currentUser } = useCurrentUser();
 
    const getPartOfDayGreeting = () => {
        const hour = new Date().getHours();
        if (hour <= 12) return "Good morning";
        if (hour <= 18) return "Good afternoon";
        return "Good evening";
    };
 
    const greeting = getPartOfDayGreeting();
 
    if (!currentUser || !currentUser.loggedIn) {
        return (
            <div data-testid={"HomePage-main-div"}>
                <BasicLayout>
                    <h1 data-testid="homePage-title" style={{ fontSize: "75px", borderRadius: "7px", backgroundColor: "white", opacity: ".9" }} className="text-center border-0 my-3">
                        {greeting}, cgaucho
                    </h1>
                </BasicLayout>
            </div>
        );
    }
 
    // Stryker disable all : TODO: restructure this code to avoid the need for this disable
    return (
        <div data-testid={"HomePage-main-div"}>
            <BasicLayout>
                <h1 data-testid="homePage-title" style={{ fontSize: "75px", borderRadius: "7px", backgroundColor: "white", opacity: ".9" }} className="text-center border-0 my-3">
                    {greeting}, {currentUser.root.user.githubLogin}
                </h1>
            </BasicLayout>
        </div>
    );
}