Esempio n. 1
0
    .flatMap(function(actual) {
      if (!isJSONorJSONParsable(actual)) {
        console.log('***************************************************');
        console.log('**      Invalid Actual Result    **');
        console.log(actual);
        console.log('***************************************************');
        return Rx.Observable.throw('actual (above) is neither JSON nor string parsable as JSON');
      }

      if (updateAll) {
        return Rx.Observable.return(JSON.stringify(actual, null, '  '))
        .let(RxFs.createWriteObservable(expectedPath));
      }

      if (typeof expected === 'undefined') {
        console.log('*********************************************************');
        console.log('**         New Test - No Expected JSON Available       **');
        console.log('** Saving actual JSON (below) to:                      **');
        console.log('** ' + expectedPath.green.bold + ' **');
        console.log('*********************************************************');
        displayActualJson(actual);
        return Rx.Observable.return(JSON.stringify(actual, null, '  '))
        .let(RxFs.createWriteObservable(expectedPath));
      }

      var outputPath;
      return compareJsonAndHandleMismatches.call(testCoordinator, expected, actual)
      .flatMap(function(userResponseOnFailure) {
        console.log('userResponseOnFailure:"' + userResponseOnFailure + '"');
        if (!expectedPath) {
          return Rx.Observable.throw('No expectedPath');
        } else if (userResponseOnFailure === 'save') {
          outputPath = expectedPath;
        } else if (userResponseOnFailure === 'next') {
          outputPath = expectedPath + '.FAILED-' + new Date().toISOString() + '.jsonld';
        } else {
          return Rx.Observable.throw('Unknown response:' + userResponseOnFailure);
        }

        return Rx.Observable.return(JSON.stringify(actual, null, '  '))
        .let(RxFs.createWriteObservable(outputPath));
      });
    });
Esempio n. 2
0
      .flatMap(function(userResponseOnFailure) {
        console.log('userResponseOnFailure:"' + userResponseOnFailure + '"');
        if (!expectedPath) {
          return Rx.Observable.throw('No expectedPath');
        } else if (userResponseOnFailure === 'save') {
          outputPath = expectedPath;
        } else if (userResponseOnFailure === 'next') {
          outputPath = expectedPath + '.FAILED-' + new Date().toISOString() + '.jsonld';
        } else {
          return Rx.Observable.throw('Unknown response:' + userResponseOnFailure);
        }

        return Rx.Observable.return(JSON.stringify(actual, null, '  '))
        .let(RxFs.createWriteObservable(outputPath));
      });