<commit_before>'use strict';

var should = require('chai').should();
var nock = require('nock');
var request = require('request');

var apiStatusCheck = require('../mfp_functions/apiStatusCheck.js');

describe('apiStatusCheck', function(){
  it('should be a function', function(){
    (typeof apiStatusCheck).should.equal('function');
  });

  it("should pass an array with an error message when npmmfp's diary is not 'public'", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for public profiles");
    });
  });

  it("should pass an array with an error message when npmmfpprivate's diary is not 'private'", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for private profiles");
    });
  });

  it("should pass an array with an error message when invalid diaries are handled differently", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for invalid usernames");
    });
  });

  it("should pass an array with an error message when fetching all nutrient data from a date doesn't work", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public-wrong-data.html')
      .get("/food/diary/npmmfp?date=2014-09-14")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("fetchSingleDate with all nutrients isn't working correctly");
    });
  });

  it("should pass an array with an error message when fetching use-specified nutrient data from a date doesn't work", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfp?date=2014-09-14")
      .replyWithFile(200, __dirname + '/mocks/diary-public-wrong-data.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("fetchSingleDate with user-specified nutrients isn't working correctly");
    });
  });

});<commit_msg>(feat) add multi-error test to apiStatCheck spec<commit_after>'use strict';

var should = require('chai').should();
var nock = require('nock');
var request = require('request');

var apiStatusCheck = require('../mfp_functions/apiStatusCheck.js');

describe('apiStatusCheck', function(){
  it('should be a function', function(){
    (typeof apiStatusCheck).should.equal('function');
  });

  it("should pass an array with an error message when npmmfp's diary is not 'public'", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for public profiles");
    });
  });

  it("should pass an array with an error message when npmmfpprivate's diary is not 'private'", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for private profiles");
    });
  });

  it("should pass an array with an error message when invalid diaries are handled differently", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("diaryStatusCheck isn't working correctly for invalid usernames");
    });
  });

  it("should pass an array with an error message when fetching all nutrient data from a date doesn't work", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public-wrong-data.html')
      .get("/food/diary/npmmfp?date=2014-09-14")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("fetchSingleDate with all nutrients isn't working correctly");
    });
  });

  it("should pass an array with an error message when fetching user-specified nutrient data from a date doesn't work", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfp?date=2014-09-14")
      .replyWithFile(200, __dirname + '/mocks/diary-public-wrong-data.html');

    apiStatusCheck(function(errors){
      (errors[0]).should.equal("fetchSingleDate with user-specified nutrients isn't working correctly");
    });
  });

  it("should pass an array with multiple error messages when encountering multiple broken functions", function(){
    nock("http://www.myfitnesspal.com")
      .get("/food/diary/npmmfp")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/npmmfpprivate")
      .replyWithFile(200, __dirname + '/mocks/diary-private.html')
      .get("/food/diary/asdfkjb3Abfdalk")
      .replyWithFile(200, __dirname + '/mocks/diary-invalid.html')
      .get("/food/diary/npmmfp?date=2014-09-13")
      .replyWithFile(200, __dirname + '/mocks/diary-public.html')
      .get("/food/diary/npmmfp?date=2014-09-14")
      .replyWithFile(200, __dirname + '/mocks/diary-public-wrong-data.html');

    apiStatusCheck(function(errors){
      (errors).should.include("diaryStatusCheck isn't working correctly for public profiles");
      (errors).should.include("fetchSingleDate with user-specified nutrients isn't working correctly");
    });
  });

});
{'fraction_non_alphanumeric': 0.1672940192388122, 'fraction_numerical': 0.03094939355918026, 'mean_word_length': 3.618541767262192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 11, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732897', 'n_tokens_mistral': 3432, 'n_tokens_neox': 3180, 'n_words': 534}