File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import { render , screen } from '@testing-library/react' ;
2+ import { MemoryRouter } from 'react-router-dom' ;
3+ import { userEvent } from '@testing-library/user-event' ;
4+ import { ListItem } from '../src/components/ListItem' ;
5+ import { mockShoppingListData } from '../src/mocks/__fixtures__/shoppingListData' ;
6+
7+ describe ( 'ListItem Component' , ( ) => {
8+ test ( 'displays additional item information if More Information button is clicked' , async ( ) => {
9+ render (
10+ < MemoryRouter >
11+ < ListItem
12+ item = { mockShoppingListData [ 1 ] }
13+ listPath = { '/groceries' }
14+ itemUrgencyStatus = "overdue"
15+ />
16+ </ MemoryRouter > ,
17+ ) ;
18+
19+ const moreInformationIcon = screen . getByTestId ( 'MoreHorizIcon' ) ;
20+ await userEvent . click ( moreInformationIcon ) ;
21+
22+ expect ( screen . getByText ( mockShoppingListData [ 1 ] . name ) ) . toBeInTheDocument ( ) ;
23+ expect (
24+ screen . getByText (
25+ `Item added on: ${ mockShoppingListData [ 1 ] . dateCreated . toDate ( ) . toLocaleString ( ) } ` ,
26+ ) ,
27+ ) . toBeInTheDocument ( ) ;
28+ expect (
29+ screen . getByText (
30+ `Last bought on: ${ mockShoppingListData [ 1 ] . dateLastPurchased . toDate ( ) . toLocaleString ( ) } ` ,
31+ ) ,
32+ ) . toBeInTheDocument ( ) ;
33+ expect (
34+ screen . getByText (
35+ `Expected to buy again by: ${ mockShoppingListData [ 1 ] . dateNextPurchased . toDate ( ) . toLocaleString ( ) } ` ,
36+ ) ,
37+ ) . toBeInTheDocument ( ) ;
38+ } ) ;
39+ } ) ;
You can’t perform that action at this time.
0 commit comments