Tiny, but fully loaded test-runner.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
476 B

const { isPromise } = require('../util');
const createRejectionStatement = (statement, ...args) =>
Promise.reject(statement ? statement(...args) : '');
const _assertPromise = (bool, statementTuple) => {
const [ statement, ...args ] = statementTuple;
if(isPromise(bool))
return bool.catch(() =>
createRejectionStatement(statement, ...args));
return bool
? Promise.resolve()
: createRejectionStatement(statement, ...args);
};
module.exports = _assertPromise;