Skip to content

Commit

Permalink
Fix another test
Browse files Browse the repository at this point in the history
  • Loading branch information
youssef-lr committed Feb 25, 2024
1 parent 1869a6b commit 53feadb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/unit/NetworkTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Onyx from 'react-native-onyx';
import _ from 'underscore';
import CONST from '../../src/CONST';
import * as App from '../../src/libs/actions/App';
import OnyxUpdateManager from '../../src/libs/actions/OnyxUpdateManager';
import * as PersistedRequests from '../../src/libs/actions/PersistedRequests';
import * as PersonalDetails from '../../src/libs/actions/PersonalDetails';
Expand Down Expand Up @@ -102,8 +101,7 @@ describe('NetworkTests', () => {
);

// This should first trigger re-authentication and then a Failed to fetch
App.confirmReadyToOpenApp();
App.openApp();
PersonalDetails.openPersonalDetails();
return waitForBatchedUpdates()
.then(() => Onyx.set(ONYXKEYS.NETWORK, {isOffline: false}))
.then(() => {
Expand All @@ -114,11 +112,11 @@ describe('NetworkTests', () => {
return waitForBatchedUpdates();
})
.then(() => {
// Then we will eventually have 3 calls to chatList and 2 calls to Authenticate
const callsToOpenApp = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'OpenApp');
// Then we will eventually have 1 call to OpenPersonalDetailsPage and 1 calls to Authenticate
const callsToOpenPersonalDetails = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'OpenPersonalDetailsPage');
const callsToAuthenticate = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'Authenticate');

expect(callsToOpenApp.length).toBe(1);
expect(callsToOpenPersonalDetails.length).toBe(1);
expect(callsToAuthenticate.length).toBe(1);
});
});
Expand Down Expand Up @@ -177,9 +175,9 @@ describe('NetworkTests', () => {
.then(() => {
// We should expect to see the three calls to OpenApp, but only one call to Authenticate.
// And we should also see the reconnection callbacks triggered.
const callsToAReadCommand = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'OpenPersonalDetailsPage');
const callsToOpenPersonalDetails = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'OpenPersonalDetailsPage');
const callsToAuthenticate = _.filter(HttpUtils.xhr.mock.calls, ([command]) => command === 'Authenticate');
expect(callsToAReadCommand.length).toBe(3);
expect(callsToOpenPersonalDetails.length).toBe(3);
expect(callsToAuthenticate.length).toBe(1);
expect(reconnectionCallbacksSpy.mock.calls.length).toBe(3);
});
Expand Down

0 comments on commit 53feadb

Please sign in to comment.