Skip to content

Commit

Permalink
Fixed some eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gedu committed Oct 2, 2024
1 parent ccadfd6 commit 0877308
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/libs/actions/PersistedRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Onyx.connect({
persistedRequests = val ?? [];

if (ongoingRequest && persistedRequests.length > 0) {
const nextRequestToProcess = persistedRequests[0];
const nextRequestToProcess = persistedRequests.at(0);

// We try to remove the next request from the persistedRequests if it is the same as ongoingRequest
// so we don't process it twice.
Expand All @@ -35,6 +35,7 @@ Onyx.connect({
*/
function clear() {
ongoingRequest = null;
Onyx.set(ONYXKEYS.PERSISTED_ONGOING_REQUESTS, null);
return Onyx.set(ONYXKEYS.PERSISTED_REQUESTS, []);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/actions/SessionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Session', () => {
await waitForBatchedUpdates();

expect(PersistedRequests.getAll().length).toBe(1);
expect(PersistedRequests.getAll()[0].command).toBe(WRITE_COMMANDS.RECONNECT_APP);
expect(PersistedRequests.getAll().at(0)?.command).toBe(WRITE_COMMANDS.RECONNECT_APP);

await Onyx.set(ONYXKEYS.NETWORK, {isOffline: false});

Expand All @@ -140,7 +140,7 @@ describe('Session', () => {
await waitForBatchedUpdates();

expect(PersistedRequests.getAll().length).toBe(1);
expect(PersistedRequests.getAll()[0].command).toBe(WRITE_COMMANDS.RECONNECT_APP);
expect(PersistedRequests.getAll().at(0)?.command).toBe(WRITE_COMMANDS.RECONNECT_APP);

await Onyx.set(ONYXKEYS.NETWORK, {isOffline: false});

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/PersistedRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('PersistedRequests', () => {
PersistedRequests.processNextRequest();
return waitForBatchedUpdates().then(() => {
expect(PersistedRequests.getAll().length).toBe(1);
expect(PersistedRequests.getAll()[0]).toEqual(request2);
expect(PersistedRequests.getAll().at(0)).toEqual(request2);
});
});

Expand All @@ -68,7 +68,7 @@ describe('PersistedRequests', () => {
failureData: [{key: 'reportMetadata_2', onyxMethod: 'set', value: {}}],
};
PersistedRequests.update(0, newRequest);
expect(PersistedRequests.getAll()[0]).toEqual(newRequest);
expect(PersistedRequests.getAll().at(0)).toEqual(newRequest);
});

it('update the ongoing request with new data', () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/SequentialQueueTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('SequentialQueue', () => {
expect(PersistedRequests.getLength()).toBe(1);
// We know there is only one request in the queue, so we can get the first one and verify
// that the persisted request is the second one.
const persistedRequest = PersistedRequests.getAll()[0];
const persistedRequest = PersistedRequests.getAll().at(0);
expect(persistedRequest?.data?.accountID).toBe(56789);
});

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('SequentialQueue', () => {
const persistedRequests = PersistedRequests.getAll();
// We know ReconnectApp is at index 1 in the queue, so we can get it to verify
// that was replaced by the new request.
expect(persistedRequests[1]?.data?.accountID).toBe(56789);
expect(persistedRequests.at(1)?.data?.accountID).toBe(56789);
});

// need to test a rance condition between processing the next request and then pushing a new request with conflict resolver
Expand Down Expand Up @@ -223,8 +223,8 @@ describe('SequentialQueue', () => {

// We know ReconnectApp is at index 9 in the queue, so we can get it to verify
// that was replaced by the new request.
expect(persistedRequests[9]?.command).toBe('ReconnectApp-replaced');
expect(persistedRequests[9]?.data?.accountID).toBe(56789);
expect(persistedRequests.at(9)?.command).toBe('ReconnectApp-replaced');
expect(persistedRequests.at(9)?.data?.accountID).toBe(56789);
});

// I need to test now when moving the request from the queue to the ongoing request the PERSISTED_REQUESTS is decreased and PERSISTED_ONGOING_REQUESTS has the new request
Expand Down

0 comments on commit 0877308

Please sign in to comment.