Skip to content

Commit

Permalink
[TS migration][G3] Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-rebelo committed Mar 8, 2024
1 parent de50342 commit e6cdbd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/unit/SidebarTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
11 changes: 9 additions & 2 deletions tests/utils/TestHelper.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,7 +19,13 @@ type MockFetch = ReturnType<typeof jest.fn> & {
resume?: () => Promise<void>;
};

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<Response>) => void;

type FormData = {
Expand Down Expand Up @@ -51,7 +58,7 @@ function signInWithTestUser(accountID = 1, login = '[email protected]', password = '

HttpUtils.xhr = jest.fn().mockImplementation(() => {
// Your mocked response object
const mockedResponse = {
const mockedResponse: Response = {
onyxData: [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit e6cdbd9

Please sign in to comment.