|
1 | 1 | import {renderHook} from '@testing-library/react-native';
|
2 | 2 | import Onyx from 'react-native-onyx';
|
3 | 3 | import useReportIsArchived from '@hooks/useReportIsArchived';
|
4 |
| -import {canModifyTask, completeTestDriveTask} from '@libs/actions/Task'; |
| 4 | +import {canModifyTask, completeTestDriveTask, getFinishOnboardingTaskOnyxData} from '@libs/actions/Task'; |
5 | 5 | // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking
|
6 | 6 | import * as API from '@libs/API';
|
7 | 7 | import {WRITE_COMMANDS} from '@libs/API/types';
|
| 8 | +import DateUtils from '@libs/DateUtils'; |
8 | 9 | import Parser from '@libs/Parser';
|
9 | 10 | // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking
|
10 | 11 | import * as ReportUtils from '@libs/ReportUtils';
|
@@ -141,4 +142,33 @@ describe('actions/Task', () => {
|
141 | 142 | expect(writeSpy).toHaveBeenCalledWith(WRITE_COMMANDS.COMPLETE_TASK, expect.anything(), expect.anything());
|
142 | 143 | });
|
143 | 144 | });
|
| 145 | + |
| 146 | + describe('getFinishOnboardingTaskOnyxData', () => { |
| 147 | + const parentReport: Report = LHNTestUtils.getFakeReport(); |
| 148 | + const taskReport: Report = {...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.TASK, ownerAccountID: 1, managerID: 2, parentReportID: parentReport.reportID}; |
| 149 | + const reportCollectionDataSet: ReportCollectionDataSet = { |
| 150 | + [`${ONYXKEYS.COLLECTION.REPORT}${taskReport.reportID}`]: taskReport, |
| 151 | + [`${ONYXKEYS.COLLECTION.REPORT}${parentReport.reportID}`]: parentReport, |
| 152 | + }; |
| 153 | + beforeEach(async () => { |
| 154 | + await Onyx.clear(); |
| 155 | + await Onyx.multiSet({ |
| 156 | + ...reportCollectionDataSet, |
| 157 | + }); |
| 158 | + await Onyx.set(ONYXKEYS.SESSION, {email: '[email protected]', accountID: 2}); |
| 159 | + await Onyx.set(`${ONYXKEYS.NVP_INTRO_SELECTED}`, {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM, setupCategories: taskReport.reportID}); |
| 160 | + await waitForBatchedUpdates(); |
| 161 | + }); |
| 162 | + it('Return not empty object', () => { |
| 163 | + expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBeGreaterThan(0); |
| 164 | + }); |
| 165 | + it('Return empty object', async () => { |
| 166 | + const reportNameValuePairs = { |
| 167 | + private_isArchived: DateUtils.getDBTime(), |
| 168 | + }; |
| 169 | + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport.reportID}`, reportNameValuePairs); |
| 170 | + await waitForBatchedUpdates(); |
| 171 | + expect(Object.values(getFinishOnboardingTaskOnyxData('setupCategories')).length).toBe(0); |
| 172 | + }); |
| 173 | + }); |
144 | 174 | });
|
0 commit comments