forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReportUtilsTest.js
574 lines (517 loc) · 25.6 KB
/
ReportUtilsTest.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import CONST from '../../src/CONST';
import * as ReportUtils from '../../src/libs/ReportUtils';
import ONYXKEYS from '../../src/ONYXKEYS';
import * as LHNTestUtils from '../utils/LHNTestUtils';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
// Be sure to include the mocked permissions library or else the beta tests won't work
jest.mock('../../src/libs/Permissions');
const currentUserEmail = '[email protected]';
const currentUserAccountID = 5;
const participantsPersonalDetails = {
1: {
accountID: 1,
displayName: 'Ragnar Lothbrok',
firstName: 'Ragnar',
login: '[email protected]',
},
2: {
accountID: 2,
login: '[email protected]',
displayName: '[email protected]',
},
3: {
accountID: 3,
displayName: 'Lagertha Lothbrok',
firstName: 'Lagertha',
login: '[email protected]',
pronouns: 'She/her',
},
4: {
accountID: 4,
login: '[email protected]',
displayName: '(833) 240-3627',
},
5: {
accountID: 5,
displayName: 'Lagertha Lothbrok',
firstName: 'Lagertha',
login: '[email protected]',
pronouns: 'She/her',
},
};
const policy = {
policyID: 1,
name: 'Vikings Policy',
};
Onyx.init({keys: ONYXKEYS});
describe('ReportUtils', () => {
beforeAll(() => {
Onyx.multiSet({
[ONYXKEYS.PERSONAL_DETAILS_LIST]: participantsPersonalDetails,
[ONYXKEYS.SESSION]: {email: currentUserEmail, accountID: currentUserAccountID},
[ONYXKEYS.COUNTRY_CODE]: 1,
[`${ONYXKEYS.COLLECTION.POLICY}${policy.policyID}`]: policy,
});
return waitForBatchedUpdates();
});
beforeEach(() => Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.DEFAULT).then(waitForBatchedUpdates));
describe('getIconsForParticipants', () => {
it('returns sorted avatar source by name, then accountID', () => {
const participants = ReportUtils.getIconsForParticipants([1, 2, 3, 4, 5], participantsPersonalDetails);
expect(participants).toHaveLength(5);
expect(participants[0].source).toBeInstanceOf(Function);
expect(participants[0].name).toBe('(833) 240-3627');
expect(participants[0].id).toBe(4);
expect(participants[0].type).toBe('avatar');
expect(participants[1].source).toBeInstanceOf(Function);
expect(participants[1].name).toBe('[email protected]');
expect(participants[1].id).toBe(2);
expect(participants[1].type).toBe('avatar');
});
});
describe('getDisplayNamesWithTooltips', () => {
test('withSingleParticipantReport', () => {
const participants = ReportUtils.getDisplayNamesWithTooltips(participantsPersonalDetails, false);
expect(participants).toHaveLength(5);
expect(participants[0].displayName).toBe('(833) 240-3627');
expect(participants[0].login).toBe('[email protected]');
expect(participants[2].avatar).toBeInstanceOf(Function);
expect(participants[2].displayName).toBe('Lagertha Lothbrok');
expect(participants[2].login).toBe('[email protected]');
expect(participants[2].accountID).toBe(3);
expect(participants[2].pronouns).toBe('She/her');
expect(participants[4].avatar).toBeInstanceOf(Function);
expect(participants[4].displayName).toBe('Ragnar Lothbrok');
expect(participants[4].login).toBe('[email protected]');
expect(participants[4].accountID).toBe(1);
expect(participants[4].pronouns).toBeUndefined();
});
});
describe('getReportName', () => {
describe('1:1 DM', () => {
test('with displayName', () => {
expect(
ReportUtils.getReportName({
participantAccountIDs: [currentUserAccountID, 1],
}),
).toBe('Ragnar Lothbrok');
});
test('no displayName', () => {
expect(
ReportUtils.getReportName({
participantAccountIDs: [currentUserAccountID, 2],
}),
).toBe('[email protected]');
});
test('SMS', () => {
expect(
ReportUtils.getReportName({
participantAccountIDs: [currentUserAccountID, 4],
}),
).toBe('(833) 240-3627');
});
});
test('Group DM', () => {
expect(
ReportUtils.getReportName({
participantAccountIDs: [currentUserAccountID, 1, 2, 3, 4],
}),
).toBe('Ragnar, [email protected], Lagertha, (833) 240-3627');
});
describe('Default Policy Room', () => {
const baseAdminsRoom = {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
reportName: '#admins',
};
test('Active', () => {
expect(ReportUtils.getReportName(baseAdminsRoom)).toBe('#admins');
});
test('Archived', () => {
const archivedAdminsRoom = {
...baseAdminsRoom,
statusNum: CONST.REPORT.STATUS.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
};
expect(ReportUtils.getReportName(archivedAdminsRoom)).toBe('#admins (archived)');
return Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES).then(() => expect(ReportUtils.getReportName(archivedAdminsRoom)).toBe('#admins (archivado)'));
});
});
describe('User-Created Policy Room', () => {
const baseUserCreatedRoom = {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
reportName: '#VikingsChat',
};
test('Active', () => {
expect(ReportUtils.getReportName(baseUserCreatedRoom)).toBe('#VikingsChat');
});
test('Archived', () => {
const archivedPolicyRoom = {
...baseUserCreatedRoom,
statusNum: CONST.REPORT.STATUS.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
};
expect(ReportUtils.getReportName(archivedPolicyRoom)).toBe('#VikingsChat (archived)');
return Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES).then(() => expect(ReportUtils.getReportName(archivedPolicyRoom)).toBe('#VikingsChat (archivado)'));
});
});
describe('PolicyExpenseChat', () => {
describe('Active', () => {
test('as member', () => {
expect(
ReportUtils.getReportName({
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
policyID: policy.policyID,
isOwnPolicyExpenseChat: true,
ownerAccountID: 1,
}),
).toBe('Vikings Policy');
});
test('as admin', () => {
expect(
ReportUtils.getReportName({
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
policyID: policy.policyID,
isOwnPolicyExpenseChat: false,
ownerAccountID: 1,
}),
).toBe('Ragnar Lothbrok');
});
});
describe('Archived', () => {
const baseArchivedPolicyExpenseChat = {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
ownerAccountID: 1,
policyID: policy.policyID,
oldPolicyName: policy.name,
statusNum: CONST.REPORT.STATUS.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
};
test('as member', () => {
const memberArchivedPolicyExpenseChat = {
...baseArchivedPolicyExpenseChat,
isOwnPolicyExpenseChat: true,
};
expect(ReportUtils.getReportName(memberArchivedPolicyExpenseChat)).toBe('Vikings Policy (archived)');
return Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES).then(() =>
expect(ReportUtils.getReportName(memberArchivedPolicyExpenseChat)).toBe('Vikings Policy (archivado)'),
);
});
test('as admin', () => {
const adminArchivedPolicyExpenseChat = {
...baseArchivedPolicyExpenseChat,
isOwnPolicyExpenseChat: false,
};
expect(ReportUtils.getReportName(adminArchivedPolicyExpenseChat)).toBe('Ragnar Lothbrok (archived)');
return Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES).then(() =>
expect(ReportUtils.getReportName(adminArchivedPolicyExpenseChat)).toBe('Ragnar Lothbrok (archivado)'),
);
});
});
});
});
describe('requiresAttentionFromCurrentUser', () => {
it('returns false when there is no report', () => {
expect(ReportUtils.requiresAttentionFromCurrentUser()).toBe(false);
});
it('returns false when the matched IOU report does not have an owner accountID', () => {
const report = {
...LHNTestUtils.getFakeReport(),
ownerAccountID: undefined,
hasOutstandingIOU: true,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});
it('returns false when the linked iou report has an oustanding IOU', () => {
const report = {
...LHNTestUtils.getFakeReport(),
iouReportID: '1',
};
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}1`, {
reportID: '1',
ownerAccountID: 99,
hasOutstandingIOU: true,
}).then(() => {
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});
});
it('returns false when the report has no outstanding IOU but is waiting for a bank account and the logged user is the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: false,
ownerAccountID: currentUserAccountID,
isWaitingOnBankAccount: true,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});
it('returns false when the report has outstanding IOU and is not waiting for a bank account and the logged user is the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: true,
ownerAccountID: currentUserAccountID,
isWaitingOnBankAccount: false,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});
it('returns false when the report has no oustanding IOU but is waiting for a bank account and the logged user is not the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: false,
ownerAccountID: 97,
isWaitingOnBankAccount: true,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(false);
});
it('returns true when the report has an unread mention', () => {
const report = {
...LHNTestUtils.getFakeReport(),
isUnreadWithMention: true,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(true);
});
it('returns true when the report is an outstanding task', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.TASK,
managerID: currentUserAccountID,
isUnreadWithMention: false,
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(true);
});
it('returns true when the report has oustanding child request', () => {
const report = {
...LHNTestUtils.getFakeReport(),
ownerAccountID: 99,
hasOutstandingIOU: true,
hasOutstandingChildRequest: true,
isWaitingOnBankAccount: false,
};
expect(ReportUtils.requiresAttentionFromCurrentUser(report)).toBe(true);
});
});
describe('getMoneyRequestOptions', () => {
const participantsAccountIDs = _.keys(participantsPersonalDetails);
beforeAll(() => {
Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {
[currentUserAccountID]: {
accountID: currentUserAccountID,
login: currentUserEmail,
},
});
});
afterAll(() => Onyx.clear());
describe('return empty iou options if', () => {
it('participants aray contains excluded expensify iou emails', () => {
const allEmpty = _.every(CONST.EXPENSIFY_ACCOUNT_IDS, (accountID) => {
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions({}, [currentUserAccountID, accountID], []);
return moneyRequestOptions.length === 0;
});
expect(allEmpty).toBe(true);
});
it('it is a room with no participants except self', () => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], []);
expect(moneyRequestOptions.length).toBe(0);
});
it('its not your policy expense chat', () => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
isOwnPolicyExpenseChat: false,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], []);
expect(moneyRequestOptions.length).toBe(0);
});
it('its paid IOU report', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.IOU,
statusNum: CONST.REPORT.STATUS.REIMBURSED,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], []);
expect(moneyRequestOptions.length).toBe(0);
});
it('its approved Expense report', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.EXPENSE,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.APPROVED,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], []);
expect(moneyRequestOptions.length).toBe(0);
});
it('its paid Expense report', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.EXPENSE,
statusNum: CONST.REPORT.STATUS.REIMBURSED,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], []);
expect(moneyRequestOptions.length).toBe(0);
});
it('it is an expense report tied to a policy expense chat user does not own', () => {
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}100`, {
reportID: '100',
isOwnPolicyExpenseChat: false,
}).then(() => {
const report = {
...LHNTestUtils.getFakeReport(),
parentReportID: '100',
type: CONST.REPORT.TYPE.EXPENSE,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(0);
});
});
});
describe('return only iou split option if', () => {
it('it is a chat room with more than one participant', () => {
const onlyHaveSplitOption = _.every(
[CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE, CONST.REPORT.CHAT_TYPE.DOMAIN_ALL, CONST.REPORT.CHAT_TYPE.POLICY_ROOM],
(chatType) => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, participantsAccountIDs[0]], []);
return moneyRequestOptions.length === 1 && moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT);
},
);
expect(onlyHaveSplitOption).toBe(true);
});
it('has multiple participants excluding self', () => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, ...participantsAccountIDs], []);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true);
});
it('user has send money permission', () => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true);
});
it("it's a group DM report", () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.CHAT,
participantsAccountIDs: [currentUserAccountID, ...participantsAccountIDs],
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true);
});
});
describe('return only money request option if', () => {
it("it is an expense report tied to user's own policy expense chat", () => {
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}101`, {
reportID: '101',
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
isOwnPolicyExpenseChat: true,
}).then(() => {
const report = {
...LHNTestUtils.getFakeReport(),
parentReportID: '101',
type: CONST.REPORT.TYPE.EXPENSE,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
});
});
it('it is an IOU report in submitted state', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.IOU,
state: CONST.REPORT.STATE.SUBMITTED,
stateNum: CONST.REPORT.STATE_NUM.PROCESSING,
statusNum: CONST.REPORT.STATUS.SUBMITTED,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, participantsAccountIDs[0]], []);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
});
it('it is an IOU report in submitted state even with send money permissions', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.IOU,
state: CONST.REPORT.STATE.SUBMITTED,
stateNum: CONST.REPORT.STATE_NUM.PROCESSING,
statusNum: CONST.REPORT.STATUS.SUBMITTED,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, participantsAccountIDs[0]], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(1);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
});
});
describe('return multiple money request option if', () => {
it("it is user's own policy expense chat", () => {
const report = {
...LHNTestUtils.getFakeReport(),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
isOwnPolicyExpenseChat: true,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(2);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true);
});
it('it is a 1:1 DM', () => {
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.CHAT,
};
const moneyRequestOptions = ReportUtils.getMoneyRequestOptions(report, [currentUserAccountID, participantsAccountIDs[0]], [CONST.BETAS.IOU_SEND]);
expect(moneyRequestOptions.length).toBe(2);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.REQUEST)).toBe(true);
expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SEND)).toBe(true);
});
});
});
describe('getReportIDFromLink', () => {
it('should get the correct reportID from a deep link', () => {
expect(ReportUtils.getReportIDFromLink('new-expensify://r/75431276')).toBe('75431276');
expect(ReportUtils.getReportIDFromLink('https://www.expensify.cash/r/75431276')).toBe('75431276');
expect(ReportUtils.getReportIDFromLink('https://staging.new.expensify.com/r/75431276')).toBe('75431276');
expect(ReportUtils.getReportIDFromLink('https://dev.new.expensify.com/r/75431276')).toBe('75431276');
expect(ReportUtils.getReportIDFromLink('https://staging.expensify.cash/r/75431276')).toBe('75431276');
expect(ReportUtils.getReportIDFromLink('https://new.expensify.com/r/75431276')).toBe('75431276');
});
it("shouldn't get the correct reportID from a deep link", () => {
expect(ReportUtils.getReportIDFromLink('new-expensify-not-valid://r/75431276')).toBe('');
expect(ReportUtils.getReportIDFromLink('new-expensify://settings')).toBe('');
});
});
describe('sortReportsByLastRead', () => {
it('should filter out report without reportID & lastReadTime and sort lastReadTime in ascending order', () => {
const reports = {
1: {reportID: 1, lastReadTime: '2023-07-08 07:15:44.030'},
2: {reportID: 2, lastReadTime: null},
3: {reportID: 3, lastReadTime: '2023-07-06 07:15:44.030'},
4: {reportID: 4, lastReadTime: '2023-07-07 07:15:44.030', type: CONST.REPORT.TYPE.IOU},
5: {lastReadTime: '2023-07-09 07:15:44.030'},
6: {reportID: 6},
7: {},
};
const sortedReports = [
{reportID: 3, lastReadTime: '2023-07-06 07:15:44.030'},
{reportID: 4, lastReadTime: '2023-07-07 07:15:44.030', type: CONST.REPORT.TYPE.IOU},
{reportID: 1, lastReadTime: '2023-07-08 07:15:44.030'},
];
expect(ReportUtils.sortReportsByLastRead(reports)).toEqual(sortedReports);
});
});
});