<commit_before>/*!
 * helper-apidocs <https://github.com/jonschlinkert/helper-apidocs>
 *
 * Copyright (c) 2014 <NAME>, contributors.
 * Licensed under the MIT License
 */

'use strict';

var should = require('should');
var handlebars = require('handlebars');
var Template = require('template');
var _ = require('lodash');
var helper = require('./');

describe('sync', function () {
  it('should generate API docs from the given file:', function () {
    var res = helper.sync("fixtures/a.js");
    (/### \[\.one\]/.test(res)).should.be.true;
  });

  it('should generate API docs from a glob of files:', function () {
    var res = helper.sync("fixtures/*.js");
    (/### \[\.one\]/.test(res)).should.be.true;
    (/### \[\.four\]/.test(res)).should.be.true;
  });

  it('should work as a lodash helper:', function () {
    var res = _.template('<%= apidocs("fixtures/a.js") %>', {}, {imports: {apidocs: helper.sync}});
    (/### \[\.one\]/.test(res)).should.be.true;
  });

  it('should work as a lodash mixin:', function () {
    _.mixin({apidocs: helper.sync});
    var res = _.template('<%= _.apidocs("fixtures/a.js") %>', {});
    (/### \[\.one\]/.test(res)).should.be.true;
  });

  it('should work as a handlebars helper:', function () {
    handlebars.registerHelper('apidocs', helper.sync);
    var res = handlebars.compile('{{apidocs "fixtures/a.js"}}')();
    (/### \[\.one\]/.test(res)).should.be.true;
  });

  it('should work with Template:', function () {
    var template = new Template();
    template.helper('apidocs', helper.sync);
    template.page('docs', {content: '<%= apidocs("fixtures/a.js") %>'});
    (/### \[\.one\]/.test(template.render('docs'))).should.be.true;
  });
});

describe('helper apidocs', function () {
  it('should work with Template:', function (done) {
    var template = new Template();
    template.asyncHelper('apidocs', helper);
    template.page('docs', {content: '<%= apidocs("fixtures/a.js") %>'});
    template.render('docs', function (err, content) {
      if (err) return done(err);
      (/### \[\.one\]/.test(content)).should.be.true;
      done();
    });
  });

  it('should generate API docs from the given file:', function () {
    helper("fixtures/a.js", function (err, content) {
      (/### \[\.one\]/.test(content)).should.be.true;
    });
  });

  it('should generate API docs from a glob of files:', function () {
    helper("fixtures/*.js", function (err, content) {
      (/### \[\.one\]/.test(content)).should.be.true;
      (/### \[\.four\]/.test(content)).should.be.true;
    });
  });
});
<commit_msg>use `.match()`<commit_after>/*!
 * helper-apidocs <https://github.com/jonschlinkert/helper-apidocs>
 *
 * Copyright (c) 2014 <NAME>, contributors.
 * Licensed under the MIT License
 */

'use strict';

var should = require('should');
var handlebars = require('handlebars');
var Template = require('template');
var _ = require('lodash');
var helper = require('./');

describe('sync', function () {
  it('should generate API docs from the given file:', function () {
    var res = helper.sync("fixtures/a.js");
    res.should.match(/### \[\.one\]/);
  });

  it('should generate API docs from a glob of files:', function () {
    var res = helper.sync("fixtures/*.js");
    res.should.match(/### \[\.one\]/);
    res.should.match(/### \[\.four\]/);
  });

  it('should work as a lodash helper:', function () {
    var res = _.template('<%= apidocs("fixtures/a.js") %>', {imports: {apidocs: helper.sync}})({});
    res.should.match(/### \[\.one\]/);
  });

  it('should work as a lodash mixin:', function () {
    _.mixin({apidocs: helper.sync});
    var res = _.template('<%= _.apidocs("fixtures/a.js") %>')({});
    res.should.match(/### \[\.one\]/);
  });

  it('should work as a handlebars helper:', function () {
    handlebars.registerHelper('apidocs', helper.sync);
    var res = handlebars.compile('{{apidocs "fixtures/a.js"}}')();
    res.should.match(/### \[\.one\]/);
  });

  it('should work with Template:', function () {
    var template = new Template();
    template.helper('apidocs', helper.sync);
    template.page('docs', {content: '<%= apidocs("fixtures/a.js") %>'});
    template.render('docs').should.match(/### \[\.one\]/);
  });
});

describe('helper apidocs', function () {
  it('should work with Template:', function (done) {
    var template = new Template();
    template.asyncHelper('apidocs', helper);
    template.page('docs', {content: '<%= apidocs("fixtures/a.js") %>'});
    template.render('docs', function (err, content) {
      if (err) return done(err);
      content.should.match(/### \[\.one\]/);
      done();
    });
  });

  it('should generate API docs from the given file:', function () {
    helper("fixtures/a.js", function (err, content) {
      content.should.match(/### \[\.one\]/);
    });
  });

  it('should generate API docs from a glob of files:', function () {
    helper("fixtures/*.js", function (err, content) {
      content.should.match(/### \[\.one\]/);
      content.should.match(/### \[\.four\]/);
    });
  });
});

{'fraction_non_alphanumeric': 0.24059405940594059, 'fraction_numerical': 0.0015841584158415843, 'mean_word_length': 3.284139100932994, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '5838783', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1623, 'n_words': 362}