use explicit .then and .catch instead of .finally for node 8.x

This commit is contained in:
Robin Malfait 2020-08-28 15:32:42 +02:00
parent 62eaac4b08
commit ce75f65347
No known key found for this signature in database
GPG key ID: 92F53D68B9041AFE

View file

@ -8,9 +8,13 @@ function suppressConsoleLogs(cb, type = 'warn') {
return () => {
const spy = jest.spyOn(global.console, type).mockImplementation(jest.fn())
return new Promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
Promise.resolve(cb()).then(resolve, reject)
}).finally(() => spy.mockRestore())
})
promise.then(spy.mockRestor, spy.mockRestore)
return promise
}
}