From e6cdbd96e714be5486721540fdf60e7ae7b40991 Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Fri, 8 Mar 2024 14:35:54 +0000 Subject: [PATCH] [TS migration][G3] Feedback --- tests/unit/SidebarTest.ts | 8 ++++---- tests/utils/TestHelper.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index c913f5a2900d..846c714ce19d 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -59,11 +59,11 @@ describe('Sidebar', () => { waitForBatchedUpdates() // When Onyx is updated with the data and the sidebar re-renders .then(() => { - const reportCollection = { + const reportCollection: ReportActionCollectionDataSet = { [`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, } as ReportCollectionDataSet; - const reportAction = { + const reportAction: ReportActionCollectionDataSet = { [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`]: {[action.reportActionID]: action}, } as ReportActionCollectionDataSet; @@ -111,11 +111,11 @@ describe('Sidebar', () => { waitForBatchedUpdates() // When Onyx is updated with the data and the sidebar re-renders .then(() => { - const reportCollection = { + const reportCollection: ReportCollectionDataSet = { [`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, } as ReportCollectionDataSet; - const reportAction = { + const reportAction: ReportActionCollectionDataSet = { [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`]: {[action.reportActionID]: action}, } as ReportActionCollectionDataSet; diff --git a/tests/utils/TestHelper.ts b/tests/utils/TestHelper.ts index a9f72a40cf3f..097433e8813d 100644 --- a/tests/utils/TestHelper.ts +++ b/tests/utils/TestHelper.ts @@ -1,4 +1,5 @@ import Str from 'expensify-common/lib/str'; +import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import CONST from '@src/CONST'; import * as Session from '@src/libs/actions/Session'; @@ -18,7 +19,13 @@ type MockFetch = ReturnType & { resume?: () => Promise; }; -type Response = {ok: boolean; json: () => Promise<{jsonCode: number}>}; +type Response = { + ok?: boolean; + json?: () => Promise<{jsonCode: number}>; + jsonCode?: number; + onyxData?: OnyxUpdate[]; +}; + type QueueItem = (value: Response | PromiseLike) => void; type FormData = { @@ -51,7 +58,7 @@ function signInWithTestUser(accountID = 1, login = 'test@user.com', password = ' HttpUtils.xhr = jest.fn().mockImplementation(() => { // Your mocked response object - const mockedResponse = { + const mockedResponse: Response = { onyxData: [ { onyxMethod: Onyx.METHOD.MERGE,