src/jasmine-mox-matchers.js
function createPromiseWith(actual, expected, verb) {
  assertPromise(actual);
  const success = jasmine.createSpy('Promise success callback');
  const failure = jasmine.createSpy('Promise failure callback');

  actual.then(success, failure);
  createScope().$digest();

  const spy = verb === 'resolved' ? success : failure;
  let pass = false;
  let message = `Expected promise to have been ${verb} with ${jasmine.pp(expected)} but it was not ${verb} at all`;

  if (isJasmine2 ? spy.calls.any() : spy.calls.length) {
    const actualResult = isJasmine2 ? spy.calls.mostRecent().args[0] : spy.mostRecentCall.args[0];
    if (angular.isFunction(expected)) {
      expected(actualResult);
      pass = true;
    } else {
      pass = angular.equals(actualResult, expected);
    }

    message = `Expected promise {not} to have been ${verb} with ${jasmine.pp(expected)} but was ${verb} with \
${jasmine.pp(actualResult)}`;
  }

  return getResult(`to${verb === 'resolved' ? 'Resolve' : 'Reject'}With`, pass, message);
}
function createPromiseWith(actual, expected, verb) {
  assertPromise(actual);
  const success = jasmine.createSpy('Promise success callback');
  const failure = jasmine.createSpy('Promise failure callback');

  actual.then(success, failure);
  createScope().$digest();

  const spy = verb === 'resolved' ? success : failure;
  let pass = false;
  let message = `Expected promise to have been ${verb} with ${jasmine.pp(expected)} but it was not ${verb} at all`;

  if (isJasmine2 ? spy.calls.any() : spy.calls.length) {
    const actualResult = isJasmine2 ? spy.calls.mostRecent().args[0] : spy.mostRecentCall.args[0];
    if (angular.isFunction(expected)) {
      expected(actualResult);
      pass = true;
    } else {
      pass = angular.equals(actualResult, expected);
    }

    message = `Expected promise {not} to have been ${verb} with ${jasmine.pp(expected)} but was ${verb} with \
${jasmine.pp(actualResult)}`;
  }

  return getResult(`to${verb === 'resolved' ? 'Resolve' : 'Reject'}With`, pass, message);
}
function createPromiseWith ( actual , expected , verb ) { assertPromise ( actual ) ; const success = jasmine . createSpy ( 'Promise success callback' ) ; const failure = jasmine . createSpy ( 'Promise failure callback' ) ; actual . then ( success , failure ) ; createScope ( ) . $digest ( ) ; const spy = verb === 'resolved' ? success : failure ; let pass = false ; let message = ` ${ verb } ${ jasmine . pp ( expected ) } ${ verb } ` ; if ( isJasmine2 ? spy . calls . any ( ) : spy . calls . length ) { const actualResult = isJasmine2 ? spy . calls . mostRecent ( ) . args [ 0 ] : spy . mostRecentCall . args [ 0 ] ; if ( angular . isFunction ( expected ) ) { expected ( actualResult ) ; pass = true ; } else { pass = angular . equals ( actualResult , expected ) ; } message = ` ${ verb } ${ jasmine . pp ( expected ) } ${ verb } \
 ${ jasmine . pp ( actualResult ) } ` ; } return getResult ( ` ${ verb === 'resolved' ? 'Resolve' : 'Reject' } ` , pass , message ) ; }
Helper function to create returns for to...With matchers

@param {*} actual the test subject
@param {*} expected value to match against
@param {string} verb 'rejected' or 'resolved'
@returns {boolean}
Helper function to create returns for to ... With matchers