<commit_before>var path = require('path');
var assert = require('chai').assert;
var WebpackAssetsManifest = require('../src/webpack-assets-manifest');
var makeCompiler = require('./fixtures/makeCompiler');

describe('WebpackAssetsManifest', function() {
  describe('#getExtension()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return the file extension', function() {
      assert.equal('.css', manifest.getExtension('main.css'));
    });

    it('should return two extensions for known formats', function() {
      assert.equal('.js.map', manifest.getExtension('main.js.map'));
      assert.equal('.css.map', manifest.getExtension('main.css.map'));
      assert.equal('.tar.gz', manifest.getExtension('archive.tar.gz'));
      assert.equal('.ext', manifest.getExtension('some.unknown.ext'));
    });

    it('should return empty string when filename is undefined or empty', function() {
      assert.equal('', manifest.getExtension());
      assert.equal('', manifest.getExtension(''));
    });

    it('should return empty string when filename does not have an extension', function() {
      assert.equal('', manifest.getExtension('no-extension'));
    });

    it('should ignore query string and fragment', function() {
      assert.equal('.js', manifest.getExtension('main.js?a=1'));
      assert.equal('.js', manifest.getExtension('main.js#b'));
      assert.equal('.js', manifest.getExtension('main.js?a=1#b'));
    });
  });

  describe('#toJSON()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return an object', function() {
      assert.deepEqual({}, manifest.toJSON());
      assert.equal('{}', JSON.stringify(manifest));
    });
  });

  describe('#toString()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return a JSON string', function() {
      assert.equal('{}', manifest.toString());
      assert.equal('{}', manifest + '');
    });
  });

  describe('#processAssets()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should process assets', function() {
      assert.deepEqual({}, manifest.moduleAssets);

      manifest.processAssets({
        common: [
          'common-123456.js',
          'common-123456.js.map'
        ],
        main: [
          'main.123456.css',
          'main.123456.css.map'
        ]
      });

      assert.deepEqual(
        {
          'common.js': 'common-123456.js',
          'common.js.map': 'common-123456.js.map',
          'main.css': 'main.123456.css',
          'main.css.map': 'main.123456.css.map'
        },
        manifest.moduleAssets
      );
    });
  });

  describe('#getStatsData()', function() {
    it('should return statistics from webpack');
  });

  describe('#getOutputPath()', function() {
    it('should work with an absolute output path', function() {
      var manifest = new WebpackAssetsManifest({
        output: '/manifest.json'
      });

      manifest.apply(makeCompiler());

      assert.equal('/manifest.json',  manifest.getOutputPath());
    });

    it('should work with a relative output path', function() {
      var manifest = new WebpackAssetsManifest({
        output: '../manifest.json'
      });

      manifest.apply(makeCompiler());

      assert.equal(
        path.resolve(__dirname, 'manifest.json'),
        manifest.getOutputPath()
      );
    });
  });

  describe('options.sortManifest', function() {
    var assets = {
      a: [ 'a.js' ],
      c: [ 'c.js' ],
      d: [ 'd.js' ],
      b: [ 'b.js' ]
    };

    it('should turn on sorting', function() {
      var manifest = new WebpackAssetsManifest({
        sortManifest: true
      });

      manifest.processAssets(assets);
<commit_msg>Updated tests<commit_after>var path = require('path');
var assert = require('chai').assert;
var WebpackAssetsManifest = require('../src/webpack-assets-manifest');
var makeCompiler = require('./fixtures/makeCompiler');

describe('WebpackAssetsManifest', function() {
  describe('#getExtension()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return the file extension', function() {
      assert.equal('.css', manifest.getExtension('main.css'));
    });

    it('should return two extensions for known formats', function() {
      assert.equal('.js.map', manifest.getExtension('main.js.map'));
      assert.equal('.css.map', manifest.getExtension('main.css.map'));
      assert.equal('.tar.gz', manifest.getExtension('archive.tar.gz'));
      assert.equal('.ext', manifest.getExtension('some.unknown.ext'));
    });

    it('should return empty string when filename is undefined or empty', function() {
      assert.equal('', manifest.getExtension());
      assert.equal('', manifest.getExtension(''));
    });

    it('should return empty string when filename does not have an extension', function() {
      assert.equal('', manifest.getExtension('no-extension'));
    });

    it('should ignore query string and fragment', function() {
      assert.equal('.js', manifest.getExtension('main.js?a=1'));
      assert.equal('.js', manifest.getExtension('main.js#b'));
      assert.equal('.js', manifest.getExtension('main.js?a=1#b'));
    });
  });

  describe('#toJSON()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return an object', function() {
      assert.deepEqual({}, manifest.toJSON());
      assert.equal('{}', JSON.stringify(manifest));
    });
  });

  describe('#toString()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should return a JSON string', function() {
      assert.equal('{}', manifest.toString());
      assert.equal('{}', manifest + '');
    });
  });

  describe('#processAssets()', function() {
    var manifest = new WebpackAssetsManifest();

    it('should process assets', function() {
      assert.deepEqual({}, manifest.moduleAssets);

      manifest.processAssets({
        common: [
          'common-123456.js',
          'common-123456.js.map'
        ],
        main: [
          'main.123456.css',
          'main.123456.css.map'
        ]
      });

      assert.deepEqual(
        {
          'common.js': 'common-123456.js',
          'common.js.map': 'common-123456.js.map',
          'main.css': 'main.123456.css',
          'main.css.map': 'main.123456.css.map'
        },
        manifest.moduleAssets
      );
    });
  });

  describe('#getStatsData()', function() {
    it('should return statistics from webpack');
  });

  describe('#getOutputPath()', function() {
    it('should work with an absolute output path', function() {
      var manifest = new WebpackAssetsManifest({
        output: '/manifest.json'
      });

      manifest.apply(makeCompiler());

      assert.equal('/manifest.json',  manifest.getOutputPath());
    });

    it('should work with a relative output path', function() {
      var manifest = new WebpackAssetsManifest({
        output: '../manifest.json'
      });

      manifest.apply(makeCompiler());

      assert.equal(
        path.resolve(__dirname, 'manifest.json'),
        manifest.getOutputPath()
      );
    });

    it('should output manifest in compiler output.path by default', function() {
      var manifest = new WebpackAssetsManifest();
      var compiler = makeCompiler();

      manifest.apply(compiler);

      assert.equal(
        compiler.options.output.path,
        path.dirname(manifest.getOutputPath())
      );
    });
  });

  describe('options.sortManifest', function() {
    var assets = {
      a: [ 'a.js' ],
      c: [ 'c.js' ],
      d: [ 'd.js' ],
      b: [ 'b.js' ]
    };

    it('should turn on sorting', function() {
      var manifest = new WebpackAssetsManifest({
        sortManifest: true
      });

      manifest.processAssets(assets);

{'fraction_non_alphanumeric': 0.1736727085743669, 'fraction_numerical': 0.012855122766422419, 'mean_word_length': 2.8783649052841476, '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': '2167706', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2184, 'n_words': 451}