<commit_before><commit_msg>create policy assertions lib<commit_after>/**
 * @fileOverview Policy item assertions helper.
 */
var chai = require('chai');

var policyAssert = module.exports = {};

/** Perform all Assertions */
policyAssert.all = function(item, expected) {
  policyAssert.properties(item);
  policyAssert.types(item);
  policyAssert.values(item, expected);
};

/** Perform property Assertions */
policyAssert.properties = function(item) {
  var assert = chai.assert;
  assert.isObject(item);
  assert.property(item, 'prop: name');
  assert.property(item, 'prop: maxTokens');
  assert.property(item, 'prop: limit');
  assert.property(item, 'prop: period');
};

/** Assert props are of correct type */
policyAssert.types = function(item) {
  var assert = chai.assert;
  assert.isString(item.name, 'type: name');
  assert.isNumber(item.maxTokens, 'type: maxTokens');
  assert.isNumber(item.limit, 'type: limit');
  assert.isString(item.period, 'type: period');
};

/** Assert values match */
policyAssert.values = function(item, optExpected) {
  var assert = chai.assert;
  var expected = optExpected || {};
  assert.equal(item.name, expected.name || 'free');
  assert.equal(item.maxTokens, expected.limit || 3);
  assert.equal(item.limit, expected.limit || 10);
  assert.equal(item.period, expected.period || 'month');
};

{'fraction_non_alphanumeric': 0.1619190404797601, 'fraction_numerical': 0.0022488755622188904, 'mean_word_length': 4.959821428571429, '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': '3284246', 'n_tokens_mistral': 415, 'n_tokens_neox': 412, 'n_words': 93}