<commit_before>
/*******************************************************************************
 * Copyright (c) 2016 <NAME>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the license at http://www.apache.org/licenses/LICENSE-2.0
 *
 * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
 * IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
 * MERCHANTABLITY OR NON-INFRINGEMENT.
 *
 * See the Apache Version 2.0 License for specific language governing
 * permissions and limitations under the License.
 *
 * Contributors - initial API implementation:
 * <NAME> <<EMAIL>>
 ******************************************************************************/

'use strict';

/*!
 * Module dependencies
 */
const bodyParser = require('body-parser');
const express = require('express');
const formidable = require('formidable');
const fs = require('fs-extra');
const http = require('http');
const HttpClient = require('../');

const port = 9999;
const host = "127.0.0.1";

describe("Test yahc", function () {

  // Set express app to test the rest client
  const app = express();
  app
  .use(
    bodyParser
    .json(
      {
        strict: true,
        inflate: true,
        limit: "5mb"
      }
    )
  );
  app
  .use(
    bodyParser
    .urlencoded(
      {
        extended: false,
        inflate: true, 
        limit: "5mb",
        parameterLimit: 1000
      }
    )
  );
  app.get("/get", function (req, res) {
    res.send("Come up to meet you, tell you I'm sorry");
  });
  app.get("/get-json", function (req, res) {
    res.status(200).json({message: "Come up to meet you, tell you I'm sorry"});
  });
  app.post("/post", function (req, res) {

  });
  app.post("/post-json", function (req, res) {

  });
  app.post("/post-form-data", function (req, res) {

  });
  app.put("/put", function (req, res) {

  });
  app.put("/put-json", function (req, res) {

  });
  app.put("/put-form-data", function (req, res) {

  });
  app.delete("/delete", function (req, res) {

  });
  app.delete("/delete-json", function (req, res) {

  });
  http.createServer(app).listen(9999, '127.0.0.1');


  it(
    "GET - application/x-www-form-urlencoded", 
    function (done) {
      HttpClient.get({
        url: "http://" + host + ":" + port + "/get",
        headers: {},
        qs: {},
        encType: HttpClient.ENC_TYPES.X_WWW_FORM_URLENCODED,
        isJson: false,
        timeout: 3000
      })
      .then((response) => {
        console.log(response);
        done();
      })
      .catch((err) => {
        console.log(err);
        done();
      });  
    }
  );

  it(
    "GET - application/x-www-form-urlencoded - json", 
    function (done) {
       HttpClient.get({
        url: "http://" + host + ":" + port + "/get-json",
        headers: {},
        qs: {},
        encType: HttpClient.ENC_TYPES.X_WWW_FORM_URLENCODED,
        isJson: true,
        timeout: 3000
      })
      .then((response) => {
        console.log(response);
        done();
      })
      .catch((err) => {
        console.log(err);<commit_msg>Added some tests for method get<commit_after>
/*******************************************************************************
 * Copyright (c) 2016 <NAME>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the license at http://www.apache.org/licenses/LICENSE-2.0
 *
 * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
 * IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
 * MERCHANTABLITY OR NON-INFRINGEMENT.
 *
 * See the Apache Version 2.0 License for specific language governing
 * permissions and limitations under the License.
 *
 * Contributors - initial API implementation:
 * <NAME> <<EMAIL>>
 ******************************************************************************/

'use strict';

/*!
 * Module dependencies
 */
const bodyParser = require('body-parser');
const express = require('express');
const formidable = require('formidable');
const fs = require('fs-extra');
const http = require('http');
const HttpClient = require('../');

const port = 9999;
const host = "127.0.0.1";

describe("Test yahc", function () {

  // Set express app to test the rest client
  const app = express();
  app
  .use(
    bodyParser
    .json(
      {
        strict: true,
        inflate: true,
        limit: "5mb"
      }
    )
  );
  app
  .use(
    bodyParser
    .urlencoded(
      {
        extended: false,
        inflate: true, 
        limit: "5mb",
        parameterLimit: 1000
      }
    )
  );
  app.get("/get", function (req, res) {
    res.send("Come up to meet you, tell you I'm sorry");
  });
  app.get("/get-json", function (req, res) {
    res.status(200).json({message: "Come up to meet you, tell you I'm sorry"});
  });
  app.post("/post", function (req, res) {

  });
  app.post("/post-json", function (req, res) {

  });
  app.post("/post-form-data", function (req, res) {

  });
  app.put("/put", function (req, res) {

  });
  app.put("/put-json", function (req, res) {

  });
  app.put("/put-form-data", function (req, res) {

  });
  app.delete("/delete", function (req, res) {

  });
  app.delete("/delete-json", function (req, res) {

  });
  http.createServer(app).listen(9999, '127.0.0.1');


  it(
    "GET - application/x-www-form-urlencoded", 
    function (done) {
      HttpClient.get({
        url: "http://" + host + ":" + port + "/get",
        headers: {},
        qs: {},
        encType: HttpClient.ENC_TYPES.X_WWW_FORM_URLENCODED,
        isJson: false,
        timeout: HttpClient.DEFAULT_TIMEOUT
      })
      .then((response) => {
        expect(response.body).toBe("Come up to meet you, tell you I'm sorry");
        expect(response.statusCode).toEqual(200);
        expect(response.headers).not.toBeUndefined();
        done();
      })
      .catch((err) => {
        expect(err).toBeUndefined();
        done();
      });  
    }
  );

  it(
    "GET - application/x-www-form-urlencoded - json", 
    function (done) {
       HttpClient.get({
        url: "http://" + host + ":" + port + "/get-json",
        headers: {},
        qs: {},
        encType: HttpClient.ENC_TYPES.X_WWW_FORM_URLENCODED,
        isJson: true,
        timeout: 3000
      })
      .then((response) => {
        expect(response.body)
        .toEqual({message: "Come up to meet you, tell you I'm sorry"});
        expect(response.statusCode).toEqual(200);
        expect(response.headers).not.toBeUndefined();
        done();
      })
      .catch((err) => {
        expect(err).toBeUndefined();
{'fraction_non_alphanumeric': 0.19726421886249101, 'fraction_numerical': 0.013822894168466522, 'mean_word_length': 2.6158250910983862, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 4, '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': '5343193', 'n_tokens_mistral': 2224, 'n_tokens_neox': 2100, 'n_words': 568}