<commit_before>var _ = require('underscore');
var async = require('async');
var cogs = require('..');
var crypto = require('crypto');
var expect = require('chai').expect;
var fs = require('fs');
var glob = require('glob');
var path = require('path');

var describe = global.describe;
var it = global.it;
var before = global.before;

cogs.processors.rwk.options.whitespace = true;
cogs.processors.rwk.options.plugins = [
  'rework-variant'
];

describe('Env Setup', function () {
  it('gets the base of a filename with dots', function () {
    expect(cogs.split('/a/b.html.jade.html.jade').base).to.equal('b.html.jade');
  });

  it('gets the extensions of a filename with dots', function () {
    expect(cogs.split('/a/b.html.coffee.html.jade').exts)
      .to.eql(['html', 'jade']);
  });
});

describe('Asset', function () {
  before(function (done) {
    var self = this;
    this.asset =
      cogs.asset(path.join('test', 'cases', 'coffee-script', 'a.coffee'));
    this.asset.build(function (er) {
      if (er) return done(er);
      var str = self.asset.toString();
      self.md5 = crypto.createHash('md5').update(str).digest('hex');
      done();
    });
  });

  it('can return a hex fingerprint', function () {
    expect(this.asset.fingerprint()).to.equal(this.md5);
  });

  it('can generate a fingerprinted filename', function () {
    expect(this.asset.filename()).to.equal('a.js');
    expect(this.asset.filename(true)).to.equal('a-' + this.md5 + '.js');
  });
});

describe('Expected/Actual Comparisons', function () {
  var dirs = fs.readdirSync(path.resolve('.', 'test', 'cases'));
  _.each(dirs, function (dir) {
    if (dir[0] === '.') return;
    it(dir, function (done) {
      var prefix = 'test/cases/' + dir;
      async.map([
        {file: prefix + '/a.*', method: 'build', property: 'built'},
        {file: prefix + '/expected.*', method: 'update', property: 'source'}
      ], function (obj, cb) {
        glob(obj.file, function (er, files) {
          var asset = cogs.asset(files[0]);
          asset[obj.method](function (er) {
            if (er) return cb(er);
            cb(null, asset[obj.property].trim().replace(/\n\s*/g, '\n'));
          });
        });
      }, function (er, result) {
        if (er) return done(er);
        expect(result[0]).to.equal(result[1]);
        done();
      });
    });
  });
});<commit_msg>Remove extra whitespace for test comparisons<commit_after>var _ = require('underscore');
var async = require('async');
var cogs = require('..');
var crypto = require('crypto');
var expect = require('chai').expect;
var fs = require('fs');
var glob = require('glob');
var path = require('path');

var describe = global.describe;
var it = global.it;
var before = global.before;

cogs.processors.rwk.options.whitespace = true;
cogs.processors.rwk.options.plugins = [
  'rework-variant'
];

describe('Env Setup', function () {
  it('gets the base of a filename with dots', function () {
    expect(cogs.split('/a/b.html.jade.html.jade').base).to.equal('b.html.jade');
  });

  it('gets the extensions of a filename with dots', function () {
    expect(cogs.split('/a/b.html.coffee.html.jade').exts)
      .to.eql(['html', 'jade']);
  });
});

describe('Asset', function () {
  before(function (done) {
    var self = this;
    this.asset =
      cogs.asset(path.join('test', 'cases', 'coffee-script', 'a.coffee'));
    this.asset.build(function (er) {
      if (er) return done(er);
      var str = self.asset.toString();
      self.md5 = crypto.createHash('md5').update(str).digest('hex');
      done();
    });
  });

  it('can return a hex fingerprint', function () {
    expect(this.asset.fingerprint()).to.equal(this.md5);
  });

  it('can generate a fingerprinted filename', function () {
    expect(this.asset.filename()).to.equal('a.js');
    expect(this.asset.filename(true)).to.equal('a-' + this.md5 + '.js');
  });
});

describe('Expected/Actual Comparisons', function () {
  var dirs = fs.readdirSync(path.resolve('.', 'test', 'cases'));
  _.each(dirs, function (dir) {
    if (dir[0] === '.') return;
    it(dir, function (done) {
      var prefix = 'test/cases/' + dir;
      async.map([
        {file: prefix + '/a.*', method: 'build', property: 'built'},
        {file: prefix + '/expected.*', method: 'update', property: 'source'}
      ], function (obj, cb) {
        glob(obj.file, function (er, files) {
          var asset = cogs.asset(files[0]);
          asset[obj.method](function (er) {
            if (er) return cb(er);
            cb(null, asset[obj.property].trim().replace(/\s*\n\s*/g, '\n'));
          });
        });
      }, function (er, result) {
        if (er) return done(er);
        expect(result[0]).to.equal(result[1]);
        done();
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.20763422818791946, 'fraction_numerical': 0.003355704697986577, 'mean_word_length': 3.0449533502968618, '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': '290750', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1568, 'n_words': 337}