Skip to content

Commit 1236424

Browse files
chore: write unit test for manager mctest
1 parent d7b377d commit 1236424

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

tests/unit/QuickActionUtilsTest.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as PolicyUtils from '@libs/PolicyUtils';
33
import {isQuickActionAllowed} from '@libs/QuickActionUtils';
44
import CONST from '@src/CONST';
5-
import type {Policy} from '@src/types/onyx';
5+
import type {Policy, Report} from '@src/types/onyx';
66

77
// Mock the PolicyUtils module
88
jest.mock('@libs/PolicyUtils');
@@ -82,5 +82,35 @@ describe('QuickActionUtils', () => {
8282
expect(result).toBe(false);
8383
});
8484
});
85+
describe('Manager McTest restrictions', () => {
86+
const requestScanAction = {
87+
action: CONST.QUICK_ACTIONS.REQUEST_SCAN,
88+
isFirstQuickAction: false,
89+
};
90+
91+
// Given a report with Manager McTest
92+
const reportWithManagerMcTest: Report = {
93+
reportID: '1',
94+
participants: {
95+
[CONST.ACCOUNT_ID.MANAGER_MCTEST]: {
96+
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS,
97+
},
98+
},
99+
};
100+
101+
beforeEach(() => {
102+
jest.clearAllMocks();
103+
});
104+
105+
it('should return false when report contains Manager McTest', () => {
106+
mockedPolicyUtils.shouldShowPolicy.mockReturnValue(false);
107+
108+
// When the report contains Manager McTest
109+
const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined);
110+
111+
// Then it should return false
112+
expect(result).toBe(false);
113+
});
114+
});
85115
});
86116
});

0 commit comments

Comments
 (0)