<commit_before>/* jshint mocha:true */
'use strict';

var assert = require('assert');
var Plugin = require('./');

describe('Plugin', function() {
  var plugin;

  beforeEach(function() {
    plugin = new Plugin({});
  });

  it('should be an object', function() {
    assert(plugin);
  });

  it('should have #compile method', function() {
    assert.equal(typeof plugin.compile, 'function');
  });

  it('should compile and produce valid result', function(done) {
    var content = 'var c = {};\nvar {a, b} = c;';
    var expected = 'var a = c.a;\nvar b = c.b;';

    plugin.compile({data: content, path: 'file.js'}, function(error, result) {
      assert(!error);
      assert(result.data.indexOf(expected) !== -1);
      done();
    });
  });

  describe('custom file extensions & patterns', function() {

    var basicPlugin = new Plugin({
      pattern: /\.(babel|es6|jsx)$/
    });
    var sourceMapPlugin = new Plugin({
      pattern: /\.(babel|es6|jsx)$/,
      sourceMaps: true
    });
    var content = 'let a = 1';
    var path = 'file.es6'

    it('should handle basic compilationcustom file extensions', function(done) {
      basicPlugin.compile({data: content, path: path}, function(error, result) {
        assert(!error);
        done();
      });
    });

    it('should properly link to source file in source maps', function(done) {
      sourceMapPlugin.compile({data: content, path: path}, function(error, result) {
        assert(!error);
        assert.doesNotThrow(function(){JSON.parse(result.map);});
        assert.equal(JSON.parse(result.map).sources.indexOf(path) !== -1, true);
        done();
      })
    })<commit_msg>Fix typo<commit_after>/* jshint mocha:true */
'use strict';

var assert = require('assert');
var Plugin = require('./');

describe('Plugin', function() {
  var plugin;

  beforeEach(function() {
    plugin = new Plugin({});
  });

  it('should be an object', function() {
    assert(plugin);
  });

  it('should have #compile method', function() {
    assert.equal(typeof plugin.compile, 'function');
  });

  it('should compile and produce valid result', function(done) {
    var content = 'var c = {};\nvar {a, b} = c;';
    var expected = 'var a = c.a;\nvar b = c.b;';

    plugin.compile({data: content, path: 'file.js'}, function(error, result) {
      assert(!error);
      assert(result.data.indexOf(expected) !== -1);
      done();
    });
  });

  describe('custom file extensions & patterns', function() {

    var basicPlugin = new Plugin({
      pattern: /\.(babel|es6|jsx)$/
    });
    var sourceMapPlugin = new Plugin({
      pattern: /\.(babel|es6|jsx)$/,
      sourceMaps: true
    });
    var content = 'let a = 1';
    var path = 'file.es6'

    it('should handle custom file extensions', function(done) {
      basicPlugin.compile({data: content, path: path}, function(error, result) {
        assert(!error);
        done();
      });
    });

    it('should properly link to source file in source maps', function(done) {
      sourceMapPlugin.compile({data: content, path: path}, function(error, result) {
        assert(!error);
        assert.doesNotThrow(function(){JSON.parse(result.map);});
        assert.equal(JSON.parse(result.map).sources.indexOf(path) !== -1, true);
        done();
      })
    })
{'fraction_non_alphanumeric': 0.17794028031687995, 'fraction_numerical': 0.003656307129798903, 'mean_word_length': 2.9987819732034104, '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': '688259', 'n_tokens_mistral': 1025, 'n_tokens_neox': 986, 'n_words': 258}