refactor(core): Simplify createDeferredPromise, and add tests (no-changelog) (#10811)
This commit is contained in:
committed by
GitHub
parent
d647ef41ac
commit
cef64329a9
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user