<commit_before>'use strict';

/*===============================
=            MODULES            =
===============================*/

var assert = require('chai').assert;
var expect = require('chai').expect;
var should = require('chai').should();
// Load API module
var OnboardIQ = require('../index');
// Load env props
require('dotenv').config();

/*=====  End of MODULES  ======*/

describe('OnboardIQ', function() {
  var Client = {};

  beforeEach(function() {
    Client = new OnboardIQ.Client(process.env.PRIVATE_API_KEY, process.env.API_VERSION);
  });

  describe('Methods', function() {
    it('should exist', function() {
      expect(Client).to.have.property('getApplicant');
      expect(Client).to.have.property('addApplicant');
      expect(Client).to.have.property('updateApplicant');
      expect(Client).to.have.property('listApplicants');
      expect(Client).to.have.property('deleteApplicant');
    });
  });

  describe('Applicants', function() {
    var newApplicant = {};

    beforeEach(function() {
      return Client.addApplicant({
        name: 'Jake',
        email: '<EMAIL>',
        phone_number: '5034834844',
        any: 'other',
        keys: 'that you might want'
      }).then(function(resp) {
        expect(resp.statusCode).to.match(/^20(0|1)$/);
        newApplicant = resp.data;
        return newApplicant;
      });
    });

    it('should be able to update an applicant', function() {
      if(process.env.API_VERSION === 'v2') {
        Client.updateApplicant(newApplicant.id, {
          name: 'John'
        }).then(function(applicant) {
          assert.equal(applicant.data.name, 'John');
          newApplicant = applicant;
        });
      } else {
        Client.updateApplicant(newApplicant.key, {
          name: 'John'
        }).then(function(applicant) {
          assert.equal(applicant.data.name, 'John');
          newApplicant = applicant;
        });
      }
    });

    it('should be able to list applicants', function() {
      if(process.env.API_VERSION === 'v2') {
        Client.listApplicants().then(function(resp) {
          var found = false;

          resp.applicants.forEach(function(el) {
            if(el.key === newApplicant.key) {
              found = true;
            }
          });

          assert.isTrue(found, 'the record exists');
        });
      } else {
        Client.listApplicants().then(function(resp) {
          var found = false;

          resp.data.forEach(function(el) {
            if(el.key === newApplicant.key) {
              found = true;
            }
          });

          assert.isTrue(found, 'the record exists');
        });
      }
    });

    afterEach(function() {
      if(process.env.API_VERSION === 'v2') {
        return Client.deleteApplicant(newApplicant.id).then(function(resp) {
          expect(resp.statusCode).to.match(/^20(0|4)$/);
          return resp;<commit_msg>fixed proper test for list applicant<commit_after>'use strict';

/*===============================
=            MODULES            =
===============================*/

var assert = require('chai').assert;
var expect = require('chai').expect;
var should = require('chai').should();
// Load API module
var OnboardIQ = require('../index');
// Load env props
require('dotenv').config();

/*=====  End of MODULES  ======*/

describe('OnboardIQ', function() {
  var Client = {};

  beforeEach(function() {
    Client = new OnboardIQ.Client(process.env.PRIVATE_API_KEY, process.env.API_VERSION);
  });

  describe('Methods', function() {
    it('should exist', function() {
      expect(Client).to.have.property('getApplicant');
      expect(Client).to.have.property('addApplicant');
      expect(Client).to.have.property('updateApplicant');
      expect(Client).to.have.property('listApplicants');
      expect(Client).to.have.property('deleteApplicant');
    });
  });

  describe('Applicants', function() {
    var newApplicant = {};

    beforeEach(function() {
      return Client.addApplicant({
        name: 'Jake',
        email: '<EMAIL>',
        phone_number: '5034834844',
        any: 'other',
        keys: 'that you might want'
      }).then(function(resp) {
        expect(resp.statusCode).to.match(/^20(0|1)$/);
        newApplicant = resp.data;
        return newApplicant;
      });
    });

    it('should be able to update an applicant', function() {
      if(process.env.API_VERSION === 'v2') {
        Client.updateApplicant(newApplicant.id, {
          name: 'John'
        }).then(function(applicant) {
          assert.equal(applicant.data.name, 'John');
          newApplicant = applicant;
        });
      } else {
        Client.updateApplicant(newApplicant.key, {
          name: 'John'
        }).then(function(applicant) {
          assert.equal(applicant.data.name, 'John');
          newApplicant = applicant;
        });
      }
    });

    it('should be able to list applicants', function() {
      if(process.env.API_VERSION === 'v2') {
        Client.listApplicants().then(function(resp) {
          var found = false;

          resp.applicants.forEach(function(el) {
            if(el.id === newApplicant.id) {
              found = true;
            }
          });

          assert.isTrue(found, 'the record exists');
        });
      } else {
        Client.listApplicants().then(function(resp) {
          var found = false;

          resp.data.forEach(function(el) {
            if(el.key === newApplicant.key) {
              found = true;
            }
          });

          assert.isTrue(found, 'the record exists');
        });
      }
    });

    afterEach(function() {
      if(process.env.API_VERSION === 'v2') {
        return Client.deleteApplicant(newApplicant.id).then(function(resp) {
          expect(resp.statusCode).to.match(/^20(0|4)$/);
          return resp;
{'fraction_non_alphanumeric': 0.18025751072961374, 'fraction_numerical': 0.007210300429184549, 'mean_word_length': 2.336769759450172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4505356', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1730, 'n_words': 286}