Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Reject throttleLatest promise with a string instead of an Error #26452

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('throttleLatest', () => {
const promise1 = throttledFunction(1);
const promise2 = throttledFunction(2);

await expect(promise1).rejects.toThrow('Throttled: A new call has been made.');
await expect(promise1).rejects.toEqual('Throttled: A new call has been made.');

expect(mockFunction).toHaveBeenCalledTimes(1);

Expand All @@ -41,7 +41,7 @@ describe('throttleLatest', () => {

const promise2 = throttledFunction(2);

await expect(promise1).rejects.toThrow('Throttled: A new call has been made.');
await expect(promise1).rejects.toEqual('Throttled: A new call has been made.');

jest.advanceTimersByTime(1000);

Expand Down Expand Up @@ -89,7 +89,7 @@ describe('throttleLatest', () => {
const promise2 = throttledFunction(2);

// The first promise should be rejected
await expect(promise1).rejects.toThrow('Throttled: A new call has been made.');
await expect(promise1).rejects.toEqual('Throttled: A new call has been made.');

// The second promise is scheduled to execute after the remaining time (2000 - 100 = 1900ms)
jest.advanceTimersByTime(1900);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function throttleLatest<T extends (...args: any[]) => Promise<any>>(
return new Promise((resolve, reject) => {
// If a call is already active, reject its promise
if (activeReject) {
activeReject(new Error('Throttled: A new call has been made.'));
activeReject('Throttled: A new call has been made.');
activeReject = null;
}

Expand Down
Loading