Skip to content

Commit

Permalink
Test case for possible bug, issue #426 (#427)
Browse files Browse the repository at this point in the history
Add tests cases for possible bug
  • Loading branch information
igorkamyshev authored Mar 7, 2024
1 parent add5a6c commit 2d539c2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/core/src/concurrency/__tests__/concurrency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,32 @@ describe('concurrency', async () => {
]
`);
});

test('TAKE_LATEST and 2 simultaneous requests lead to correct status, issue #426', async () => {
const q = createQuery({
async handler(id: string) {
const defer = createDefer();

onAbort(() => defer.reject());

await setTimeout(1);
defer.resolve(id);

return defer.promise;
},
});

concurrency(q, { strategy: 'TAKE_LATEST' });

const scope = fork();

allSettled(q.start, { scope, params: '1' });
allSettled(q.start, { scope, params: '2' });

expect(scope.getState(q.$pending)).toBeTruthy();

await allSettled(scope);

expect(scope.getState(q.$pending)).toBeFalsy();
});
});

0 comments on commit 2d539c2

Please sign in to comment.