Skip to content

Commit 550e95f

Browse files
committed
fix: Create unit test
1 parent 410c7a2 commit 550e95f

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/unit/ReportUtilsTest.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
canHoldUnholdReportAction,
3232
canJoinChat,
3333
canLeaveChat,
34+
canSeeDefaultRoom,
3435
canUserPerformWriteAction,
3536
findLastAccessedReport,
3637
getAllAncestorReportActions,
@@ -216,6 +217,10 @@ const personalDetails: PersonalDetailsList = {
216217
accountID: 7,
217218
login: 'owner@test.com',
218219
},
220+
'8': {
221+
accountID: 8,
222+
login: CONST.EMAIL.GUIDES_DOMAIN,
223+
},
219224
};
220225

221226
const rules = {
@@ -4877,4 +4882,38 @@ describe('ReportUtils', () => {
48774882
expect(getReportStatusTranslation(undefined, CONST.REPORT.STATUS_NUM.OPEN)).toBe('');
48784883
});
48794884
});
4885+
describe('canSeeDefaultRoom', () => {
4886+
it('should return true if report is archived room ', () => {
4887+
const betas = [CONST.BETAS.DEFAULT_ROOMS];
4888+
const report: Report = {
4889+
...createRandomReport(40002),
4890+
type: CONST.REPORT.TYPE.CHAT,
4891+
participants: buildParticipantsFromAccountIDs([currentUserAccountID, 1]),
4892+
};
4893+
expect(canSeeDefaultRoom(report, betas, true)).toBe(true);
4894+
});
4895+
it('should return true if the room has an assigned guide', () => {
4896+
const betas = [CONST.BETAS.DEFAULT_ROOMS];
4897+
const report: Report = {
4898+
...createRandomReport(40002),
4899+
participants: {
4900+
'1': {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
4901+
'8': {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS},
4902+
},
4903+
};
4904+
Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, personalDetails).then(() => {
4905+
expect(canSeeDefaultRoom(report, betas, false)).toBe(true);
4906+
});
4907+
});
4908+
it('should return true if the report is admin room', () => {
4909+
const betas = [CONST.BETAS.DEFAULT_ROOMS];
4910+
const report: Report = {
4911+
...createRandomReport(40002),
4912+
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
4913+
};
4914+
Onyx.set(ONYXKEYS.PERSONAL_DETAILS_LIST, personalDetails).then(() => {
4915+
expect(canSeeDefaultRoom(report, betas, false)).toBe(true);
4916+
});
4917+
});
4918+
});
48804919
});

0 commit comments

Comments
 (0)