refactor(core): Simplify createDeferredPromise, and add tests (no-changelog) (#10811)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-09-13 15:53:03 +02:00
committed by GitHub
parent d647ef41ac
commit cef64329a9
14 changed files with 66 additions and 43 deletions

View File

@@ -85,12 +85,12 @@ describe('ActiveExecutions', () => {
test('Should attach and resolve response promise to existing execution', async () => {
const newExecution = mockExecutionData();
await activeExecutions.add(newExecution, FAKE_EXECUTION_ID);
const deferredPromise = await mockDeferredPromise();
const deferredPromise = mockDeferredPromise();
activeExecutions.attachResponsePromise(FAKE_EXECUTION_ID, deferredPromise);
const fakeResponse = { data: { resultData: { runData: {} } } };
activeExecutions.resolveResponsePromise(FAKE_EXECUTION_ID, fakeResponse);
await expect(deferredPromise.promise()).resolves.toEqual(fakeResponse);
await expect(deferredPromise.promise).resolves.toEqual(fakeResponse);
});
test('Should remove an existing execution', async () => {
@@ -163,5 +163,5 @@ function mockFullRunData(): IRun {
// eslint-disable-next-line @typescript-eslint/promise-function-async
const mockCancelablePromise = () => new PCancelable<IRun>((resolve) => resolve());
// eslint-disable-next-line @typescript-eslint/promise-function-async
const mockDeferredPromise = () => createDeferredPromise<IExecuteResponsePromiseData>();