diff --git a/src/index-v11.js b/src/index-v11.js index 1d9b81b..11697fa 100644 --- a/src/index-v11.js +++ b/src/index-v11.js @@ -50,7 +50,7 @@ function getCypressCurrentSubject() { Cypress.Commands.add( 'if', { prevSubject: true }, - function (subject, assertion, assertionValue) { + function (subject, assertion, assertionValue1, assertionValue2) { const cmd = cy.state('current') debug('if', cmd.attributes, 'subject', subject, 'assertion?', assertion) debug('next command', cmd.next) @@ -86,18 +86,31 @@ Cypress.Commands.add( const parts = assertion.split('.') let assertionReduced = expect(subject).to parts.forEach((assertionPart, k) => { - if ( - k === parts.length - 1 && - typeof assertionValue !== 'undefined' - ) { - assertionReduced = assertionReduced[assertionPart](assertionValue) + if (k === parts.length - 1) { + if ( + typeof assertionValue1 !== 'undefined' && + typeof assertionValue2 !== 'undefined' + ) { + assertionReduced = assertionReduced[assertionPart]( + assertionValue1, + assertionValue2, + ) + } else if (typeof assertionValue1 !== 'undefined') { + assertionReduced = + assertionReduced[assertionPart](assertionValue1) + } } else { assertionReduced = assertionReduced[assertionPart] } }) } else { - if (typeof assertionValue !== 'undefined') { - expect(subject).to.be[assertion](assertionValue) + if ( + typeof assertionValue1 !== 'undefined' && + typeof assertionValue2 !== 'undefined' + ) { + expect(subject).to.be[assertion](assertionValue1, assertionValue2) + } else if (typeof assertionValue1 !== 'undefined') { + expect(subject).to.be[assertion](assertionValue1) } else { expect(subject).to.be[assertion] }