{"size": 2940, "ext": "js", "max_stars_repo_path": "regress/0_validator.js", "max_stars_repo_name": "ign-packo/PackO", "max_stars_repo_stars_event_min_datetime": "2020-12-02T16:20:16.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-03T14:06:10.000Z", "max_issues_repo_path": "regress/0_validator.js", "max_issues_repo_name": "ign-packo/PackO", "max_issues_repo_issues_event_min_datetime": "2020-08-26T13:28:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T13:19:21.000Z", "max_forks_repo_path": "regress/0_validator.js", "max_forks_repo_name": "ign-packo/PackO", "max_forks_repo_forks_event_min_datetime": "2020-08-28T08:37:42.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-19T14:55:03.000Z"}
{"max_stars_count": 4, "max_issues_count": 262, "max_forks_count": 2, "avg_line_length": 34.5882352941, "max_line_length": 109, "alphanum_fraction": 0.5020408163}
const chai = require('chai');
chai.use(require('chai-http'));

chai.should();

const validator = require('../paramValidation/validator');

describe('Validator', () => {
  describe('isCrs', () => {
    describe("without the key 'type'", () => {
      it("should return 'false'", (done) => {
        const crs = JSON.parse('{"properties": { "name": "urn:ogc:def:crs:EPSG::2154" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe('type: name', () => {
      it("should return 'true'", (done) => {
        const crs = JSON.parse('{"type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2154" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(true);
        done();
      });
    });
    describe('type: name, with invalid name', () => {
      it("should return 'false'", (done) => {
        const crs = JSON.parse('{"type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2154b" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe('type: EPSG', () => {
      it("should return 'true'", (done) => {
        const crs = JSON.parse('{"type": "EPSG", "properties": { "code": "2154" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(true);
        done();
      });
    });
    describe('type: EPSG, with invalid code', () => {
      it("should return 'false'", (done) => {
        const crs = JSON.parse('{"type": "EPSG", "properties": { "code": "2154b" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe('type: other', () => {
      it("should return 'false'", (done) => {
        const crs = JSON.parse('{"type": "other", "properties": { "other": "2154" } }');
        validator.isCrs(crs).should.be.a('boolean').equal(false);
        done();
      });
    });
  });

  describe('isColor', () => {
    describe("color = '[234, 125, 589]' (wrong format)", () => {
      it("should return 'false'", (done) => {
        const color = '[234, 125, 589]';
        validator.isColor(color).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe('color = [234, 125, 589] (value > 255)', () => {
      it("should return 'false'", (done) => {
        const color = [234, 125, 589];
        validator.isColor(color).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe('color = [234, 125] (missing a value)', () => {
      it("should return 'false'", (done) => {
        const color = [234, 125];
        validator.isColor(color).should.be.a('boolean').equal(false);
        done();
      });
    });
    describe("color = ['234', 0, 185]", () => {
      it("should return 'true'", (done) => {
        const color = ['234', 0, 185];
        validator.isColor(color).should.be.a('boolean').equal(true);
        done();
      });
    });
  });
});
