Muthu Kumar
6 years ago
1 changed files with 10 additions and 3 deletions
@ -1,9 +1,16 @@ |
|||
const { isPromise } = require('../util'); |
|||
|
|||
const _assertPromise = (bool, assertion) => { |
|||
const createRejectionStatement = (statement, ...args) => |
|||
Promise.reject(statement ? statement(...args) : ''); |
|||
|
|||
const _assertPromise = (bool, statementTuple) => { |
|||
const [ statement, ...args ] = statementTuple; |
|||
if(isPromise(bool)) |
|||
return bool.catch(() => Promise.reject(assertion)); |
|||
return bool ? Promise.resolve() : Promise.reject(assertion); |
|||
return bool.catch(() => |
|||
createRejectionStatement(statement, ...args)); |
|||
return bool |
|||
? Promise.resolve() |
|||
: createRejectionStatement(statement, ...args); |
|||
}; |
|||
|
|||
module.exports = _assertPromise; |
|||
|
Loading…
Reference in new issue