You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Merge remote-tracking branch 'origin/develop' into travis/event-fixes
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
lexicographicCompare,
|
||||
nextString,
|
||||
prevString,
|
||||
simpleRetryOperation,
|
||||
stringToBase,
|
||||
} from "../../src/utils";
|
||||
import { logger } from "../../src/logger";
|
||||
@@ -268,6 +269,34 @@ describe("utils", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('simpleRetryOperation', () => {
|
||||
it('should retry', async () => {
|
||||
let count = 0;
|
||||
const val = {};
|
||||
const fn = (attempt) => {
|
||||
count++;
|
||||
|
||||
// If this expectation fails then it can appear as a Jest Timeout due to
|
||||
// the retry running beyond the test limit.
|
||||
expect(attempt).toEqual(count);
|
||||
|
||||
if (count > 1) {
|
||||
return Promise.resolve(val);
|
||||
} else {
|
||||
return Promise.reject(new Error("Iterative failure"));
|
||||
}
|
||||
};
|
||||
|
||||
const ret = await simpleRetryOperation(fn);
|
||||
expect(ret).toBe(val);
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
|
||||
// We don't test much else of the function because then we're just testing that the
|
||||
// underlying library behaves, which should be tested on its own. Our API surface is
|
||||
// all that concerns us.
|
||||
});
|
||||
|
||||
describe('DEFAULT_ALPHABET', () => {
|
||||
it('should be usefully printable ASCII in order', () => {
|
||||
expect(DEFAULT_ALPHABET).toEqual(
|
||||
|
Reference in New Issue
Block a user