<commit_before>/*global describe, it */

'use strict';

var assert = require('assert');
var prepareConfig = require('../lib/config');

describe('gulp-responsive - config', function() {

  it('should set unspecified default value for `withoutEnlargement`', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].withoutEnlargement, true);
  });

  it('should set unspecified default value for `quality`', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].quality, 80);
  });

  it('should set unspecified default value for `progressive`', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].progressive, false);
  });

  it('should set unspecified default value for `compressionLevel`', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].compressionLevel, 6);
  });

  it('should set unspecified default value for `withMetadata`', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].withMetadata, false);
  });

  it('should not override specified values', function() {
    var config = prepareConfig([{
      name: 'gulp.png',
      width: 100,
      withoutEnlargement: false,
      quality: 96,
      progressive: true,
      compressionLevel: 8,
      withMetadata: true
    }]);

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].withoutEnlargement, false);
    assert.equal(config[0].quality, 96);
    assert.equal(config[0].progressive, true);
    assert.equal(config[0].compressionLevel, 8);
    assert.equal(config[0].withMetadata, true);
  });

  it('should parse config object', function() {
    var config = prepareConfig({
      'gulp.png': {
        width: 100
      }
    });

    assert.equal(config.length, 1);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].withoutEnlargement, true);
  });

  it('should parse config object of arrays', function() {
    var config = prepareConfig({
      'gulp.png': [{
        width: 100
      },{
        width: 200
      }]
    });

    assert.equal(config.length, 2);
    assert.equal(config[0].name, 'gulp.png');
    assert.equal(config[0].withoutEnlargement, true);
    assert.equal(config[1].name, 'gulp.png');
    assert.equal(config[1].withoutEnlargement, true);
  });
});<commit_msg>added test for global config<commit_after>/*global describe, it */

'use strict';

var assert = require('assert');
var prepareConfig = require('../lib/config');

describe('gulp-responsive', function() {

  describe('config', function () {

    it('should set unspecified default value for `withoutEnlargement`', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, true);
    });

    it('should set unspecified default value for `quality`', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].quality, 80);
    });

    it('should set unspecified default value for `progressive`', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].progressive, false);
    });

    it('should set unspecified default value for `compressionLevel`', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].compressionLevel, 6);
    });

    it('should set unspecified default value for `withMetadata`', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withMetadata, false);
    });

    it('should not override specified values', function() {
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100,
        withoutEnlargement: false,
        quality: 96,
        progressive: true,
        compressionLevel: 8,
        withMetadata: true
      }]);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, false);
      assert.equal(config[0].quality, 96);
      assert.equal(config[0].progressive, true);
      assert.equal(config[0].compressionLevel, 8);
      assert.equal(config[0].withMetadata, true);
    });

    it('should parse config object', function() {
      var config = prepareConfig({
        'gulp.png': {
          width: 100
        }
      });

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, true);
    });

    it('should parse config object of arrays', function() {
      var config = prepareConfig({
        'gulp.png': [{
          width: 100
        },{
          width: 200
        }]
      });

      assert.equal(config.length, 2);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, true);
      assert.equal(config[1].name, 'gulp.png');
      assert.equal(config[1].withoutEnlargement, true);
    });

  });

  describe('global config', function () {

    it('should override default values', function () {
      var globalConfig = {
        withoutEnlargement: false,
        quality: 50,
        progressive: true,
        compressionLevel: 5,
        withMetadata: true
      };
      var config = prepareConfig([{
        name: 'gulp.png'
      }], globalConfig);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, false);
      assert.equal(config[0].quality, 50);
      assert.equal(config[0].progressive, true);
      assert.equal(config[0].compressionLevel, 5);
      assert.equal(config[0].withMetadata, true);
    });

    it('should not override values specified per file', function () {
      var globalConfig = {
        withoutEnlargement: true,
        quality: 50,
        progressive: false,
        compressionLevel: 5,
        withMetadata: false
      };
      var config = prepareConfig([{
        name: 'gulp.png',
        width: 100,
        withoutEnlargement: false,
        quality: 96,
        progressive: true,
        compressionLevel: 8,
        withMetadata: true
      }], globalConfig);

      assert.equal(config.length, 1);
      assert.equal(config[0].name, 'gulp.png');
      assert.equal(config[0].withoutEnlargement, false);
      assert.equal(config[0].quality, 96);
      assert.equal(config[0].progressive, true);
      assert.equal(config[0].compressionLevel, 8);
      assert.equal(config[0].withMetadata, true);
    });
  });
});
{'fraction_non_alphanumeric': 0.15800977114939574, 'fraction_numerical': 0.02108511185394703, 'mean_word_length': 2.7707222491517207, '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': '4960726', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2348, 'n_words': 493}