<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var expect = require("chai").expect;
var config = require("../loop/config");

describe("config", function() {
  describe("#validateKeys", function() {
    it("should throw an error if a key is missing", function() {
      expect(function() {
        config.validateKeys(['foo'])({});
      }).to.throw(/Should have a foo property/);
    });

    it("should not throw if all keys are valid", function() {
      config.validateKeys(['foo'])({foo: 'oh yeah'});
    });

    it("should not throw any error if it is defined as optional", function() {
      config.validateKeys(['foo'], {'optional': true})({});
    });
  });

  describe("#hexKeyOfSize", function() {
    it("should check if all chars are hexadecimals", function() {
      expect(function() {
        config.hexKeyOfSize(4)("ggggaaaa");
      }).to.throw(/Should be an 4 bytes key encoded as hexadecimal/);
    });

    it("should check the size of the given key", function() {
      expect(function() {
        config.hexKeyOfSize(4)("aaaafff");
      }).to.throw(/Should be an 4 bytes key encoded as hexadecimal/);
    });
  });

  describe("sample.json", function() {
    it("should load.", function() {
      require("../config/sample.json");
    });

    it("should validates.", function() {
      var file = __dirname + '/../config/sample.json';
      config.conf.loadFile(file);
      config.conf.validate();
    });
  });
});<commit_msg>This can leak the sample configuration to test configuration.<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var expect = require("chai").expect;
var config = require("../loop/config");

describe("config", function() {
  describe("#validateKeys", function() {
    it("should throw an error if a key is missing", function() {
      expect(function() {
        config.validateKeys(['foo'])({});
      }).to.throw(/Should have a foo property/);
    });

    it("should not throw if all keys are valid", function() {
      config.validateKeys(['foo'])({foo: 'oh yeah'});
    });

    it("should not throw any error if it is defined as optional", function() {
      config.validateKeys(['foo'], {'optional': true})({});
    });
  });

  describe("#hexKeyOfSize", function() {
    it("should check if all chars are hexadecimals", function() {
      expect(function() {
        config.hexKeyOfSize(4)("ggggaaaa");
      }).to.throw(/Should be an 4 bytes key encoded as hexadecimal/);
    });

    it("should check the size of the given key", function() {
      expect(function() {
        config.hexKeyOfSize(4)("aaaafff");
      }).to.throw(/Should be an 4 bytes key encoded as hexadecimal/);
    });
  });

  describe("sample.json", function() {
    it("should load.", function() {
      require("../config/sample.json");
    });

    it.skip("should validates.", function() {
      var file = __dirname + '/../config/sample.json';
      config.conf.loadFile(file);
      config.conf.validate();
    });
  });
});
{'fraction_non_alphanumeric': 0.17391304347826086, 'fraction_numerical': 0.0047976011994002995, 'mean_word_length': 3.063337393422655, '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': '2806354', 'n_tokens_mistral': 991, 'n_tokens_neox': 962, 'n_words': 302}