etherpad-lite/src/tests/backend/specs/regression-db.ts

31 lines
863 B
TypeScript
Raw Normal View History

2021-04-18 00:50:35 +02:00
'use strict';
const AuthorManager = require('../../../node/db/AuthorManager');
import {strict as assert} from "assert";
2021-04-18 00:50:35 +02:00
const common = require('../common');
const db = require('../../../node/db/DB');
describe(__filename, function () {
let setBackup: Function;
2021-04-18 00:50:35 +02:00
before(async function () {
await common.init();
setBackup = db.set;
db.set = async (...args:any) => {
2021-04-18 00:50:35 +02:00
// delay db.set
await new Promise<void>((resolve) => { setTimeout(() => resolve(), 500); });
2021-04-18 00:50:35 +02:00
return await setBackup.call(db, ...args);
};
});
after(async function () {
db.set = setBackup;
});
it('regression test for missing await in createAuthor (#5000)', async function () {
const {authorID} = await AuthorManager.createAuthor(); // Should block until db.set() finishes.
assert(await AuthorManager.doesAuthorExist(authorID));
});
});