import * as React from 'react' ; import { render , screen } from '@testing-library/react' ; import '@testing-library/jest-dom/extend-expect' ; import { TaskCard } from './TaskCard' ; import { useBoardContext } from 'ProjectPlanner/BoardContext' ; /**
 * Mocks
 */ jest . mock ( 'ProjectPlanner/BoardContext' ) ; /**
 * Tests
 */ describe ( 'TaskCard' , ( ) => { it ( "should render with no content if async context hasn't resolved" , async ( ) => { useBoardContext . mockReturnValue ( { getTask : ( ) => null , } ) ; render ( < TaskCard />); screen . getByText ( 'No Content' ) ; } ) ; it ( 'should render the task info if async context has resolved' , async ( ) => { useBoardContext . mockReturnValue ( { getTask : ( ) => { return { taskId : 1 , name : 'fakeTaskName' , content : 'fakeTaskContent' } ; } , } ) ; render ( < TaskCard />); const taskName = screen . getByText ( 'fakeTaskName' ) ; expect ( taskName ) . toBeTruthy ( ) ; const taskContent = screen . getByText ( 'fakeTaskContent' ) ; } ) ; } ) ;