1
1
// Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
2
2
3
3
import { fromJS , Map , OrderedMap } from "immutable" ;
4
- import { ListItem , ListItemText } from "@material-ui/core" ;
5
4
6
- import Jewel from "../../../../jewel" ;
7
- import { setupMountedComponent } from "../../../../../test" ;
5
+ import { mountedComponent , screen } from "../../../../../test-utils" ;
8
6
import { FormSectionRecord , FieldRecord } from "../../../records" ;
9
7
10
8
import NavItem from "./component" ;
11
9
12
10
describe ( "<NavItem />" , ( ) => {
13
- let component ;
14
-
15
11
const record = fromJS ( {
16
12
case_id : "12345" ,
17
13
case_id_display : "3c9d076" ,
@@ -100,7 +96,7 @@ describe("<NavItem />", () => {
100
96
const props = {
101
97
form : { } ,
102
98
groupItem : false ,
103
- handleClick : ( ) => { } ,
99
+ handleClick : ( ) => { } ,
104
100
isNested : false ,
105
101
isNew : false ,
106
102
itemsOfGroup : [ ] ,
@@ -111,46 +107,18 @@ describe("<NavItem />", () => {
111
107
hasError : true
112
108
} ;
113
109
114
- beforeEach ( ( ) => {
115
- ( { component } = setupMountedComponent ( NavItem , props , initialState ) ) ;
116
- } ) ;
117
-
118
110
it ( "renders a ListItem component />" , ( ) => {
119
- expect ( component . find ( ListItem ) ) . to . have . lengthOf ( 1 ) ;
120
- } ) ;
121
-
122
- it ( "renders a ListItemText component />" , ( ) => {
123
- expect ( component . find ( ListItemText ) ) . to . have . lengthOf ( 1 ) ;
124
- } ) ;
125
-
126
- it ( "should render valid props" , ( ) => {
127
- const NavItemProps = { ...component . find ( NavItem ) . props ( ) } ;
128
-
129
- expect ( component . find ( NavItem ) ) . to . have . lengthOf ( 1 ) ;
130
- [
131
- "form" ,
132
- "groupItem" ,
133
- "handleClick" ,
134
- "isNested" ,
135
- "isNew" ,
136
- "itemsOfGroup" ,
137
- "name" ,
138
- "open" ,
139
- "recordAlerts" ,
140
- "selectedForm" ,
141
- "hasError"
142
- ] . forEach ( property => {
143
- expect ( NavItemProps ) . to . have . property ( property ) ;
144
- delete NavItemProps [ property ] ;
145
- } ) ;
146
- expect ( NavItemProps ) . to . be . empty ;
111
+ mountedComponent ( < NavItem { ...props } /> , initialState ) ;
112
+ expect ( screen . getAllByTestId ( "list-item" ) ) . toHaveLength ( 1 ) ;
147
113
} ) ;
148
114
149
115
it ( "renders a ListItemText component />" , ( ) => {
150
- expect ( component . find ( ListItemText ) ) . to . have . lengthOf ( 1 ) ;
116
+ mountedComponent ( < NavItem { ...props } /> , initialState ) ;
117
+ expect ( screen . getAllByTestId ( "list-item-text" ) ) . toHaveLength ( 1 ) ;
151
118
} ) ;
152
119
153
120
it ( "renders <Jewel/> for error" , ( ) => {
154
- expect ( component . find ( Jewel ) ) . to . have . lengthOf ( 1 ) ;
121
+ mountedComponent ( < NavItem { ...props } /> , initialState ) ;
122
+ expect ( screen . getAllByTestId ( "jewel-error" ) ) . toHaveLength ( 1 ) ;
155
123
} ) ;
156
124
} ) ;
0 commit comments