mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
1b4ebce3b0
- There is now just one way to wait until the UrlService is finished across all of our tests! - db.ready is only called in the one utility + the actual UrlService tests
32 lines
783 B
JavaScript
32 lines
783 B
JavaScript
const urlService = require('../../core/frontend/services/url');
|
|
const events = require('../../core/server/lib/common/events');
|
|
|
|
module.exports.isFinished = async (options = {disableDbReadyEvent: false}) => {
|
|
let timeout;
|
|
|
|
if (options.disableDbReadyEvent === false) {
|
|
events.emit('db.ready');
|
|
}
|
|
|
|
return new Promise(function (resolve) {
|
|
(function retry() {
|
|
clearTimeout(timeout);
|
|
|
|
if (urlService.hasFinished()) {
|
|
return resolve();
|
|
}
|
|
|
|
timeout = setTimeout(retry, 50);
|
|
})();
|
|
});
|
|
};
|
|
|
|
module.exports.reset = () => {
|
|
urlService.softReset();
|
|
},
|
|
|
|
module.exports.resetGenerators = () => {
|
|
urlService.resetGenerators();
|
|
urlService.resources.reset({ignoreDBReady: true});
|
|
};
|