mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
cef64329a9
Some checks failed
Test Master / install-and-build (push) Has been cancelled
Benchmark Docker Image CI / build (push) Has been cancelled
Test Master / Unit tests (18.x) (push) Has been cancelled
Test Master / Unit tests (20.x) (push) Has been cancelled
Test Master / Unit tests (22.4) (push) Has been cancelled
Test Master / Lint (push) Has been cancelled
Test Master / Notify Slack on failure (push) Has been cancelled
23 lines
693 B
TypeScript
23 lines
693 B
TypeScript
import { createDeferredPromise } from '@/DeferredPromise';
|
|
|
|
describe('DeferredPromise', () => {
|
|
it('should resolve the promise with the correct value', async () => {
|
|
let done = false;
|
|
const deferred = createDeferredPromise<string>();
|
|
void deferred.promise.finally(() => {
|
|
done = true;
|
|
});
|
|
expect(done).toBe(false);
|
|
deferred.resolve('test');
|
|
await expect(deferred.promise).resolves.toBe('test');
|
|
expect(done).toBe(true);
|
|
});
|
|
|
|
it('should reject the promise with the correct error', async () => {
|
|
const deferred = createDeferredPromise();
|
|
const error = new Error('test error');
|
|
deferred.reject(error);
|
|
await expect(deferred.promise).rejects.toThrow(error);
|
|
});
|
|
});
|