Skip to content

Commit

Permalink
Fix jest test part 4
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1206agra committed Sep 11, 2024
1 parent c211680 commit c9b41ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/unit/SidebarOrderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Sidebar', () => {
// Wrap Onyx each onyx action with waitForBatchedUpdates
wrapOnyxWithWaitForBatchedUpdates(Onyx);
// Initialize the network key for OfflineWithFeedback
return TestHelper.signInWithTestUser(1, '[email protected]', undefined, undefined, 'One', '').then(() => Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false}));
return TestHelper.signInWithTestUser(1, '[email protected]', undefined, undefined, 'One').then(() => Onyx.merge(ONYXKEYS.NETWORK, {isOffline: false}));
});

// Clear out Onyx after each test so that each test starts with a clean slate
Expand Down
10 changes: 5 additions & 5 deletions tests/utils/TestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ function setupApp() {
});
}

function buildPersonalDetails(login: string, accountID: number, firstName = 'Test', lastName = 'User'): PersonalDetails {
function buildPersonalDetails(login: string, accountID: number, firstName = 'Test'): PersonalDetails {
return {
accountID,
login,
avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_7.png',
avatarThumbnail: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_7.png',
displayName: `${firstName}${lastName ? '' : ` ${lastName}`}`,
displayName: `${firstName} User`,
firstName,
lastName,
lastName: 'User',
pronouns: '',
timezone: CONST.DEFAULT_TIME_ZONE,
phoneNumber: '',
Expand All @@ -66,7 +66,7 @@ function buildPersonalDetails(login: string, accountID: number, firstName = 'Tes
* Simulate signing in and make sure all API calls in this flow succeed. Every time we add
* a mockImplementationOnce() we are altering what Network.post() will return.
*/
function signInWithTestUser(accountID = 1, login = '[email protected]', password = 'Password1', authToken = 'asdfqwerty', firstName = 'Test', lastName = 'User') {
function signInWithTestUser(accountID = 1, login = '[email protected]', password = 'Password1', authToken = 'asdfqwerty', firstName = 'Test') {
const originalXhr = HttpUtils.xhr;

HttpUtils.xhr = jest.fn().mockImplementation(() => {
Expand All @@ -90,7 +90,7 @@ function signInWithTestUser(accountID = 1, login = '[email protected]', password = '
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[accountID]: buildPersonalDetails(login, accountID, firstName, lastName),
[accountID]: buildPersonalDetails(login, accountID, firstName),
},
},
],
Expand Down

0 comments on commit c9b41ad

Please sign in to comment.