<commit_before>/* eslint-env mocha */

var expect = require("chai").expect;
var fs = require("fs");
var path = require("path");
var request = require("request");
var testUtils = require("./utils");

var REP_SAMPLE_PATH = path.join(__dirname, "representative_sample.json");
var REPRESENTATIVE_SAMPLE = JSON.parse(fs.readFileSync(REP_SAMPLE_PATH));
var REPRESENTATIVE_BAR_CHART = [
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  }
];

/**
 * serverUrl
 *
 * Generate a URL used to connect to the testing server.
 *
 * @base {number} - The domain / port the server is running on.
 * @returns {string} - A URL for the server, returning the root endpoint
 */
function serverUrl(base, endpoint) {
  return base + endpoint;
}


describe("Web Server Backend", function bootingServer() {
  var serverInstance = null;
  var serverBase = null;

  before(function before(done) {
    testUtils.startServerWithAutomaticPort(function onStart(server, base, err) {
      expect(err).to.not.to.be.ok; // eslint-disable-line no-unused-expressions
      serverInstance = server;
      serverBase = base;
      done();
    });
  });

  after(function after() {
    serverInstance.close();
  });

  it("192.168.3.11 boots the server and database", function boots() {
  });

  describe("seeded with some mock data", function seededWith() {
    before(function before(done) {
      this.timeout(1000 * 500);
      testUtils.seedDatabaseWith(REPRESENTATIVE_SAMPLE).then(function onDone() {
        done();
      });
    });

    it("192.168.3.11 boots with the server and database", function boots() {
    });

    it("172.16.17.32 allows endpoint request for bar_chart", function getBC(done) {
      request.get(serverUrl(serverBase, "/get_bar_chart"), {
        qs: {
          name: "authorYear"
        }
      }, function onData(error, response, body) {
        var result = JSON.parse(body);
        expect(result.result).to.equal("success");
        expect(result.data).to.deep.equal(REPRESENTATIVE_BAR_CHART);
        done();
      });
    });
  });
});<commit_msg>test: Add test for getting nonexistent chart<commit_after>/* eslint-env mocha */

var expect = require("chai").expect;
var fs = require("fs");
var path = require("path");
var request = require("request");
var testUtils = require("./utils");

var REP_SAMPLE_PATH = path.join(__dirname, "representative_sample.json");
var REPRESENTATIVE_SAMPLE = JSON.parse(fs.readFileSync(REP_SAMPLE_PATH));
var REPRESENTATIVE_BAR_CHART = [
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  },
  {
    name: "<NAME>",
    value: 1
  }
];

/**
 * serverUrl
 *
 * Generate a URL used to connect to the testing server.
 *
 * @base {number} - The domain / port the server is running on.
 * @returns {string} - A URL for the server, returning the root endpoint
 */
function serverUrl(base, endpoint) {
  return base + endpoint;
}


describe("Web Server Backend", function bootingServer() {
  var serverInstance = null;
  var serverBase = null;

  before(function before(done) {
    testUtils.startServerWithAutomaticPort(function onStart(server, base, err) {
      expect(err).to.not.to.be.ok; // eslint-disable-line no-unused-expressions
      serverInstance = server;
      serverBase = base;
      done();
    });
  });

  after(function after() {
    serverInstance.close();
  });

  it("192.168.3.11 boots the server and database", function boots() {
  });

  describe("seeded with some mock data", function seededWith() {
    before(function before(done) {
      this.timeout(1000 * 500);
      testUtils.seedDatabaseWith(REPRESENTATIVE_SAMPLE).then(function onDone() {
        done();
      });
    });

    it("192.168.3.11 boots with the server and database", function boots() {
    });

    it("172.16.17.32 allows endpoint request for bar_chart", function getBC(done) {
      request.get(serverUrl(serverBase, "/get_bar_chart"), {
        qs: {
          name: "authorYear"
        }
      }, function onData(error, response, body) {
        var result = JSON.parse(body);
        expect(result.result).to.equal("success");
        expect(result.data).to.deep.equal(REPRESENTATIVE_BAR_CHART);
        done();
      });
    });

    it("192.168.127.12 returns an error for nonexistent charts", function retE(done) {
      request.get(serverUrl(serverBase, "/get_bar_chart"), {
        qs: {
          name: "barFoo"
        }
      }, function onData(error, response, body) {
        var result = JSON.parse(body);
        expect(result.result).to.equal("failure");
        expect(result.reason).to.match(/.*how to get chart barFoo.*/);
        done();
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.15743879472693031, 'fraction_numerical': 0.01864406779661017, 'mean_word_length': 2.7375087966220972, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 7, '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': '2078541', 'n_tokens_mistral': 1829, 'n_tokens_neox': 1721, 'n_words': 408}