@@ -91,13 +91,8 @@ describe('Read Data Tests', () => {
91
91
const { getByTestId} = render ( < App /> ) ;
92
92
93
93
// test that the 'useObject()' method worked and the correct sentence is rendered as expected
94
- const taskItemSentence = await waitFor (
95
- ( ) => getByTestId ( 'task-item-sentence' ) ,
96
- { timeout : 5000 } ,
97
- ) ;
98
- expect ( taskItemSentence . props . children . join ( '' ) ) . toBe (
99
- 'Wash the dishes is a task with the priority of: 3' ,
100
- ) ;
94
+ const taskItemSentence = await waitFor ( ( ) => getByTestId ( 'task-item-sentence' ) , { timeout : 5000 } ) ;
95
+ expect ( taskItemSentence . props . children . join ( '' ) ) . toBe ( 'Wash the dishes is a task with the priority of: 3' ) ;
101
96
} ) ;
102
97
103
98
it ( 'should filter data' , async ( ) => {
@@ -116,9 +111,7 @@ describe('Read Data Tests', () => {
116
111
const highPriorityTasks = tasks . filtered ( 'priority >= 4' ) ;
117
112
118
113
// filter for tasks that have just-started or short-running progress
119
- const lowProgressTasks = tasks . filtered (
120
- '1 <= progressMinutes && progressMinutes < 10' ,
121
- ) ;
114
+ const lowProgressTasks = tasks . filtered ( '1 <= progressMinutes && progressMinutes < 10' ) ;
122
115
return (
123
116
< >
124
117
< Text > Your high priority tasks:</ Text >
@@ -143,26 +136,14 @@ describe('Read Data Tests', () => {
143
136
const { getAllByTestId} = render ( < App /> ) ;
144
137
145
138
// test that the highPriorityTasks items Text renders
146
- const highPriorityTasksUIList = await waitFor (
147
- ( ) => getAllByTestId ( 'high-priority-element' ) ,
148
- { timeout : 5000 } ,
149
- ) ;
150
- expect ( highPriorityTasksUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe (
151
- 'Do the laundry' ,
152
- ) ; // Since only the 'Do the laundry' task is high priority
139
+ const highPriorityTasksUIList = await waitFor ( ( ) => getAllByTestId ( 'high-priority-element' ) , { timeout : 5000 } ) ;
140
+ expect ( highPriorityTasksUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ; // Since only the 'Do the laundry' task is high priority
153
141
154
142
// test that the highPriorityTasks items Text renders
155
- const lowProgressTasksUIList = await waitFor (
156
- ( ) => getAllByTestId ( 'low-progress-element' ) ,
157
- { timeout : 5000 } ,
158
- ) ;
143
+ const lowProgressTasksUIList = await waitFor ( ( ) => getAllByTestId ( 'low-progress-element' ) , { timeout : 5000 } ) ;
159
144
// test that both 'Wash the dishes' and 'Gym Workout' rendered because they are both low progress tasks
160
- expect ( lowProgressTasksUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe (
161
- 'Wash the dishes' ,
162
- ) ;
163
- expect ( lowProgressTasksUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe (
164
- 'Gym Workout' ,
165
- ) ;
145
+ expect ( lowProgressTasksUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
146
+ expect ( lowProgressTasksUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
166
147
} ) ;
167
148
168
149
it ( 'should render sorted tasks' , async ( ) => {
@@ -208,13 +189,9 @@ describe('Read Data Tests', () => {
208
189
< Text testID = 'tasks-by-name-descending-item' > { task . name } </ Text >
209
190
) ) }
210
191
211
- < Text >
212
- Tasks sorted by priority descending, and name alphabetically:
213
- </ Text >
192
+ < Text > Tasks sorted by priority descending, and name alphabetically:</ Text >
214
193
{ tasksByPriorityDescendingAndName . map ( task => (
215
- < Text testID = 'tasks-by-priority-descending-and-name-item' >
216
- { task . name }
217
- </ Text >
194
+ < Text testID = 'tasks-by-priority-descending-and-name-item' > { task . name } </ Text >
218
195
) ) }
219
196
220
197
< Text > Tasks sorted by assignee name:</ Text >
@@ -235,65 +212,33 @@ describe('Read Data Tests', () => {
235
212
const { getAllByTestId} = render ( < App /> ) ;
236
213
237
214
// test that tasks should be in the order that they were written
238
- const allTasksUIList = await waitFor (
239
- ( ) => getAllByTestId ( 'all-tasks-item' ) ,
240
- { timeout : 5000 } ,
241
- ) ;
215
+ const allTasksUIList = await waitFor ( ( ) => getAllByTestId ( 'all-tasks-item' ) , { timeout : 5000 } ) ;
242
216
expect ( allTasksUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
243
217
expect ( allTasksUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ;
244
218
expect ( allTasksUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
245
219
246
220
// test that tasksByName should be in alphabetical name order
247
- const taskByNameUIList = await waitFor (
248
- ( ) => getAllByTestId ( 'tasks-by-name-item' ) ,
249
- { timeout : 5000 } ,
250
- ) ;
221
+ const taskByNameUIList = await waitFor ( ( ) => getAllByTestId ( 'tasks-by-name-item' ) , { timeout : 5000 } ) ;
251
222
expect ( taskByNameUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ;
252
223
expect ( taskByNameUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
253
224
expect ( taskByNameUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
254
225
255
226
// test that tasksByNameDescending should be in reverse alphabetical name order
256
- const taskByNameDescendingUIList = await waitFor (
257
- ( ) => getAllByTestId ( 'tasks-by-name-descending-item' ) ,
258
- { timeout : 5000 } ,
259
- ) ;
260
- expect ( taskByNameDescendingUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe (
261
- 'Wash the dishes' ,
262
- ) ;
263
- expect ( taskByNameDescendingUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe (
264
- 'Gym Workout' ,
265
- ) ;
266
- expect ( taskByNameDescendingUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe (
267
- 'Do the laundry' ,
268
- ) ;
227
+ const taskByNameDescendingUIList = await waitFor ( ( ) => getAllByTestId ( 'tasks-by-name-descending-item' ) , { timeout : 5000 } ) ;
228
+ expect ( taskByNameDescendingUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
229
+ expect ( taskByNameDescendingUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
230
+ expect ( taskByNameDescendingUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ;
269
231
270
232
// test that tasksByNameDescending should be in reverse alphabetical name order
271
- const tasksByPriorityDescendingAndNameUIList = await waitFor ( ( ) =>
272
- getAllByTestId ( 'tasks-by-priority-descending-and-name-item' ) ,
273
- ) ;
274
- expect (
275
- tasksByPriorityDescendingAndNameUIList [ 0 ] . children [ 0 ] . toString ( ) ,
276
- ) . toBe ( 'Do the laundry' ) ;
277
- expect (
278
- tasksByPriorityDescendingAndNameUIList [ 1 ] . children [ 0 ] . toString ( ) ,
279
- ) . toBe ( 'Gym Workout' ) ;
280
- expect (
281
- tasksByPriorityDescendingAndNameUIList [ 2 ] . children [ 0 ] . toString ( ) ,
282
- ) . toBe ( 'Wash the dishes' ) ;
233
+ const tasksByPriorityDescendingAndNameUIList = await waitFor ( ( ) => getAllByTestId ( 'tasks-by-priority-descending-and-name-item' ) ) ;
234
+ expect ( tasksByPriorityDescendingAndNameUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ;
235
+ expect ( tasksByPriorityDescendingAndNameUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
236
+ expect ( tasksByPriorityDescendingAndNameUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
283
237
284
238
// test that tasksByNameDescending should be in reverse alphabetical name order
285
- const tasksByAssigneeNameUIList = await waitFor (
286
- ( ) => getAllByTestId ( 'tasks-by-assignee-name-item' ) ,
287
- { timeout : 5000 } ,
288
- ) ;
289
- expect ( tasksByAssigneeNameUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe (
290
- 'Wash the dishes' ,
291
- ) ;
292
- expect ( tasksByAssigneeNameUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe (
293
- 'Do the laundry' ,
294
- ) ;
295
- expect ( tasksByAssigneeNameUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe (
296
- 'Gym Workout' ,
297
- ) ;
239
+ const tasksByAssigneeNameUIList = await waitFor ( ( ) => getAllByTestId ( 'tasks-by-assignee-name-item' ) , { timeout : 5000 } ) ;
240
+ expect ( tasksByAssigneeNameUIList [ 0 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Wash the dishes' ) ;
241
+ expect ( tasksByAssigneeNameUIList [ 1 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Do the laundry' ) ;
242
+ expect ( tasksByAssigneeNameUIList [ 2 ] . children [ 0 ] . toString ( ) ) . toBe ( 'Gym Workout' ) ;
298
243
} ) ;
299
244
} ) ;
0 commit comments