Ghost/test/utils/url-service-utils.js
Naz 155e96b044 Fixed undefined error
refs https://github.com/TryGhost/Toolbox/issues/135

- Not all callers provide the parameter, so an empty object default saves from unecessary "undefined" errors
2021-11-22 21:56:32 +13:00

32 lines
830 B
JavaScript

const urlService = require('../../core/server/services/url');
module.exports.isFinished = async (options = {disableDbReadyEvent: false}) => {
let timeout;
return new Promise(function (resolve) {
(function retry() {
clearTimeout(timeout);
if (urlService.hasFinished()) {
return resolve();
}
timeout = setTimeout(retry, 50);
})();
});
};
// @TODO: unify all the reset/softTeset helpers so they either work how the main code works or the reasons why they are different are clear
module.exports.init = ({urlCache} = {}) => {
urlService.init({urlCache});
};
module.exports.reset = () => {
urlService.softReset();
},
module.exports.resetGenerators = () => {
urlService.resetGenerators();
urlService.resources.reset();
};