<commit_before>'use strict';

var docs = require('../docs/src/js/docs');
var expect = require('chai').expect;
var sinon = require('sinon');
var stub = sinon.stub;
var utils = require('./helpers/utils');
var each = utils.each;
var any = utils.any;
var getContextStub = require('./helpers/get-context-stub');
var Canvas = require('../lib/index.js');

describe('docs', function () {

  var element = document.createElement('canvas');
  stub(element, 'getContext', getContextStub);
  var canvas = new Canvas(element);

  it('is a list of groups', function () {
    expect(docs.length).to.be.above(1);

    each(docs, function (value) {
      expect(value.name).to.exist;
      expect(value.methods).to.exist;
    });
  });

  it('should contain all of the canvasimo methods and aliases', function () {
    each(canvas, function (value, key) {
      var anyGroupContainsTheMethod = any(docs, function (group) {
        return any(group.methods, function (method) {
          return method.name === key || method.alias === key;
        });
      });

      expect(anyGroupContainsTheMethod).to.be.true;
    });
  });
<commit_msg>Add test for group descriptions<commit_after>'use strict';

var docs = require('../docs/src/js/docs');
var expect = require('chai').expect;
var sinon = require('sinon');
var stub = sinon.stub;
var utils = require('./helpers/utils');
var each = utils.each;
var any = utils.any;
var getContextStub = require('./helpers/get-context-stub');
var Canvas = require('../lib/index.js');

describe('docs', function () {

  var element = document.createElement('canvas');
  stub(element, 'getContext', getContextStub);
  var canvas = new Canvas(element);

  it('is a list of groups', function () {
    expect(docs.length).to.be.above(1);

    each(docs, function (value) {
      expect(value.name).to.exist;
      expect(value.methods).to.exist;
    });
  });

  it('should contain all of the canvasimo methods and aliases', function () {
    each(canvas, function (value, key) {
      var anyGroupContainsTheMethod = any(docs, function (group) {
        return any(group.methods, function (method) {
          return method.name === key || method.alias === key;
        });
      });

      expect(anyGroupContainsTheMethod).to.be.true;
    });
  });

  it('should have descriptions for every group', function () {
    var totalGroups = 0;
    var documentedGroups = 0;
    var firstUndocumentedGroup;

    each(docs, function (group) {
      totalGroups += 1;

      if (group.description) {
        documentedGroups += 1;
      } else if (!firstUndocumentedGroup) {
        firstUndocumentedGroup = group.name;
      }
    });

    console.log(documentedGroups + ' of ' + totalGroups + ' groups have descriptions');

    if (firstUndocumentedGroup) {
      throw new Error(firstUndocumentedGroup + ' group has no description');
    }
  });

{'fraction_non_alphanumeric': 0.15446584938704028, 'fraction_numerical': 0.0021015761821366026, 'mean_word_length': 3.3076923076923075, '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': '4758572', 'n_tokens_mistral': 861, 'n_tokens_neox': 856, 'n_words': 212}