signal-desktop/ts/test-both/util/explodePromise_test.ts
2021-08-26 13:18:00 -05:00

24 lines
579 B
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { explodePromise } from '../../util/explodePromise';
describe('explodePromise', () => {
it('resolves the promise', async () => {
const { promise, resolve } = explodePromise<number>();
resolve(42);
assert.strictEqual(await promise, 42);
});
it('rejects the promise', async () => {
const { promise, reject } = explodePromise<number>();
reject(new Error('rejected'));
await assert.isRejected(promise, 'rejected');
});
});