From 85d684ff6a0e1dfad2f1818e9438548f96f7f0d1 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 5 Nov 2024 19:58:35 +0700 Subject: [PATCH] fix: unit test --- tests/unit/WorkspaceSettingsUtilsTest.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 3fcfd6549131..a25cec98c0f4 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx'; import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import {Report, ReportActions} from '@src/types/onyx'; +import {ReportCollectionDataSet} from '@src/types/onyx/Report'; import * as TestHelper from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; @@ -49,6 +50,21 @@ describe('WorkspacesSettingsUtils', () => { avatarFileName: '', }; + const MOCK_REPORTS: ReportCollectionDataSet = { + [`${ONYXKEYS.COLLECTION.REPORT}4286515777714555` as const]: report, + [`${ONYXKEYS.COLLECTION.REPORT}6955627196303088` as const]: { + reportID: '6955627196303088', + chatReportID: '1699789757771388', + policyID: '57D0F454E0BCE54B', + type: 'expense', + ownerAccountID: 18634488, + stateNum: 1, + statusNum: 1, + parentReportID: '1699789757771388', + parentReportActionID: '7978085421707288417', + }, + }; + const actions: OnyxCollection = { reportActions_1699789757771388: { '4007735288062946397': { @@ -540,8 +556,11 @@ describe('WorkspacesSettingsUtils', () => { }; await Onyx.multiSet({ - ...report, + ...MOCK_REPORTS, ...actions, + [ONYXKEYS.SESSION]: { + accountID: 18634488, + }, transactionViolations_3106135972713435169: [ { name: 'missingCategory', @@ -556,6 +575,8 @@ describe('WorkspacesSettingsUtils', () => { ], }); + await waitForBatchedUpdates(); + const result = getBrickRoadForPolicy(report, actions); expect(result).toBe('error'); });