mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
tests: Promisify helper.init()
This commit is contained in:
parent
c714ff1014
commit
20df34bb67
2 changed files with 21 additions and 24 deletions
|
@ -6,17 +6,16 @@ const helper = {};
|
||||||
let $iframe;
|
let $iframe;
|
||||||
const jsLibraries = {};
|
const jsLibraries = {};
|
||||||
|
|
||||||
helper.init = (cb) => {
|
helper.init = async () => {
|
||||||
$.get('../../static/js/vendors/jquery.js').done((code) => {
|
[
|
||||||
|
jsLibraries.jquery,
|
||||||
|
jsLibraries.sendkeys,
|
||||||
|
] = await Promise.all([
|
||||||
|
$.get('../../static/js/vendors/jquery.js'),
|
||||||
|
$.get('lib/sendkeys.js'),
|
||||||
|
]);
|
||||||
// make sure we don't override existing jquery
|
// make sure we don't override existing jquery
|
||||||
jsLibraries.jquery = `if(typeof $ === 'undefined') {\n${code}\n}`;
|
jsLibraries.jquery = `if (typeof $ === 'undefined') {\n${jsLibraries.jquery}\n}`;
|
||||||
|
|
||||||
$.get('lib/sendkeys.js').done((code) => {
|
|
||||||
jsLibraries.sendkeys = code;
|
|
||||||
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
helper.randomString = (len) => {
|
helper.randomString = (len) => {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$(() => {
|
// $(handler), $().ready(handler), $.wait($.ready).then(handler), etc. don't work if handler is an
|
||||||
|
// async function for some bizarre reason, so the async function is wrapped in a non-async function.
|
||||||
|
$(() => (async () => {
|
||||||
const stringifyException = (exception) => {
|
const stringifyException = (exception) => {
|
||||||
let err = exception.stack || exception.toString();
|
let err = exception.stack || exception.toString();
|
||||||
|
|
||||||
|
@ -154,15 +156,11 @@ $(() => {
|
||||||
describe(`${desc}.js`, function () { require(spec); });
|
describe(`${desc}.js`, function () { require(spec); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the test helper
|
await helper.init();
|
||||||
helper.init(() => {
|
|
||||||
// configure and start the test framework
|
|
||||||
const grep = getURLParameter('grep');
|
const grep = getURLParameter('grep');
|
||||||
if (grep != null) {
|
if (grep != null) {
|
||||||
mocha.grep(grep);
|
mocha.grep(grep);
|
||||||
}
|
}
|
||||||
|
|
||||||
const runner = mocha.run();
|
const runner = mocha.run();
|
||||||
customRunner(runner);
|
customRunner(runner);
|
||||||
});
|
})());
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in a new issue