Skip to content

Commit 4bd87e0

Browse files
committed
fix: update unit test
1 parent ce4d738 commit 4bd87e0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/unit/ExportActionsTest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ describe('Export actions', () => {
7878
expect(value).toEqual(expect.objectContaining({state: 'ready', reportCount: 5}));
7979
});
8080

81-
test('clearStaleExportDownloads calls clearExportDownload for each non-null entry', async () => {
81+
test('clearStaleExportDownloads clears failed entries but preserves preparing and ready ones', async () => {
8282
const key1 = `${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-1` as const;
8383
const key2 = `${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-2` as const;
84+
const key3 = `${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-3` as const;
8485

8586
await Onyx.mergeCollection(ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD, {
8687
[key1]: {state: 'ready'},
8788
[key2]: {state: 'failed'},
89+
[key3]: {state: 'preparing'},
8890
});
8991
await waitForBatchedUpdates();
9092

@@ -93,7 +95,9 @@ describe('Export actions', () => {
9395

9496
const value1 = await getOnyxValue(`${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-1`);
9597
const value2 = await getOnyxValue(`${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-2`);
96-
expect(value1).toBeUndefined();
98+
const value3 = await getOnyxValue(`${ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD}stale-3`);
99+
expect(value1).toEqual(expect.objectContaining({state: 'ready'}));
97100
expect(value2).toBeUndefined();
101+
expect(value3).toEqual(expect.objectContaining({state: 'preparing'}));
98102
});
99103
});

0 commit comments

Comments
 (0)