<commit_before>/* eslint-env mocha */
'use strict';
let chai = require('chai');
let expect = chai.expect;
let chaiHttp = require('chai-http');
// let server = require('../../app.js');

let Ajv = require('ajv');
let projListSchema = require('../../schema/projectList');

chai.use(chaiHttp);

let sampleProjList = [
  {'id': 1337, 'name': 'Hank'},
  {'id': 456, 'name': 'John'},
  {'id': 673, 'name': 'Frank'}
];

describe('Schema Validation for project.js', function () {
  it('JSON schema object is valid', function (done) {
    let ajv = new Ajv();
    let validate = ajv.compile(projListSchema);
    let result = validate(sampleProjList);

    expect(result).to.be.true();
    done();
  });

  /* it('JSON from rest api data structure is valid', function (done) {
    chai.request(server)
      .get('/projects')
      .end(function (err, res) {
        expect(err).to.be.null;
        expect(res).to.have.status(200);
        done();
      });
  });*/
});<commit_msg>Added 9 combinations to the tests for gatherProjects. It has been Linted.<commit_after>/* eslint-env mocha */
'use strict';
let chai = require('chai');
let expect = chai.expect;
let chaiHttp = require('chai-http');
// let server = require('../../app.js');

let Ajv = require('ajv');
let projListSchema = require('../../schema/projectList');
chai.use(chaiHttp);

let credentialFixtureCases = [
  [
    // Valid ID Valid Name
    {'id': 1337, 'name': 'Hank'},
    {'id': 456, 'name': 'John'},
    {'id': 673, 'name': 'Frank'}
  ],
  [
    // Valid ID Invalid Name
    {'id': 1337, 'name': 17},
    {'id': 456, 'name': 'John'},
    {'id': 673, 'name': 'Frank'}
  ],
  [
    // Valid ID Missing Name
    {'id': 1337},
    {'id': 456},
    {'id': 673}
  ],
  [
    // Invalid ID Valid Name
    {'id': 'Jimbo', 'name': 'Hank'},
    {'id': 456, 'name': 'John'},
    {'id': 673, 'name': 'Frank'}
  ],
  [
    // Invalid ID Valid Name
    {'id': 'Jimbo', 'name': 17},
    {'id': 456, 'name': 'John'},
    {'id': 673, 'name': 'Frank'}
  ],
  [
    // Invalid ID Missing Name
    {'id': 'Jimbo'},
    {'id': 456},
    {'id': 673}
  ],
  [
    // Missing ID Valid Name
    {'name': 'Hank'},
    {'name': 'John'},
    {'name': 'Frank'}
  ],
  [
    // Missing ID Invalid Name
    {'name': 17},
    {'name': 'John'},
    {'name': 'Frank'}
  ],
  [
    // Missing ID Missing Name
    {},
    {},
    {}
  ]
];

describe('Schema Validation for project.js', function () {
  let ajv = new Ajv();
  let validate = ajv.compile(projListSchema);
  credentialFixtureCases.forEach(function (fixture) {
    let result = validate(fixture);
    if (result === true) {
      it('Should return true when the JSON schema object is VALID\n', function () {
        expect(result).to.be.true();
      });
    } else {
      it('JSON schema object should be INVALID with the credentials\n \tname: ' + fixture[0].name + ' and ID: ' + fixture[0].id + '\n', function () {
        // console.log('\tShould be invalid with name: ' + fixture[0].name + ' and ID: ' + fixture[0].id);
        expect(result).to.not.be.true();
      });
    }
  });
});
{'fraction_non_alphanumeric': 0.2147498375568551, 'fraction_numerical': 0.023391812865497075, 'mean_word_length': 2.732121212121212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7356486', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1062, 'n_words': 284}