mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00

The previous package was outdated, preventing us from updating TS. This one also lints YAML and JSON, and applies many more rules to the test files, explaining all the changes in this PR.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { promiseSome } from '../../../src/util/PromiseUtil';
|
|
|
|
describe('PromiseUtil', (): void => {
|
|
describe('#promiseSome', (): void => {
|
|
const resultTrue = Promise.resolve(true);
|
|
const resultFalse = Promise.resolve(false);
|
|
const resultError = Promise.reject(new Error('generic error'));
|
|
const resultInfinite = new Promise<boolean>((): void => {});
|
|
|
|
it('returns false if no promise is provided.', async(): Promise<void> => {
|
|
await expect(promiseSome([])).resolves.toBe(false);
|
|
});
|
|
|
|
it('returns false if no promise returns true.', async(): Promise<void> => {
|
|
await expect(promiseSome([ resultFalse, resultFalse, resultFalse ])).resolves.toBe(false);
|
|
});
|
|
|
|
it('returns true if at least a promise returns true.', async(): Promise<void> => {
|
|
await expect(promiseSome([ resultFalse, resultTrue, resultFalse ])).resolves.toBe(true);
|
|
});
|
|
|
|
it('does not propagate errors.', async(): Promise<void> => {
|
|
await expect(promiseSome([ resultError, resultFalse, resultFalse ])).resolves.toBe(false);
|
|
});
|
|
|
|
it('works with a combination of promises.', async(): Promise<void> => {
|
|
await expect(promiseSome([ resultError, resultTrue, resultInfinite ])).resolves.toBe(true);
|
|
});
|
|
});
|
|
});
|