<commit_before>var fs = require('fs'),
    fu = require('../../lib/fileUtil'),
    lib = require('../lib'),
    watch = require('../lib/watch');

describe('stylus-config plugin', function() {
  var readFileSync = fs.readFileSync,
      readFile = fs.readFile,
      statSync = fs.statSync;
  beforeEach(function() {
    fu.lookupPath('');

    this.stub(fs, 'readFileSync', function(path) {
      if (/file1\.styl|png$/.test(path) && !/functions(?:[\\\/]index)?.styl/.test(path)) {
        return '.test\n  display $display\n';
      } else if (/lumbar\.json$/.test(path)) {
        return JSON.stringify(config);
      } else if (/two\.json$/.test(path)) {
        return '{"$display": "red","value!":10}';
      } else if (/\.json$/.test(path)) {
        return '{"$display": "black"}';
      } else {
        return readFileSync.apply(this, arguments);
      }
    });
    this.stub(fs, 'readFile', function(path, callback) {
      process.nextTick(function() {
        try {
          callback(undefined, fs.readFileSync(path));
        } catch (err) {
          callback(err);
        }
      });
    });
    this.stub(fs, 'statSync', function(path) {
      if (!/(foo|two|lumbar|file1)\.(styl|png|json)$/.test(path) || /functions(?:[\\\/]index)?.styl/.test(path)) {
        return statSync.apply(this, arguments);
      }
    });
  });

  var config = {
    'modules': {
      'test': {
        'scripts': [{'stylus-config': true}],
        'styles': ['file1.styl']
      }
    },
    'styles': {
      'config': ['two.json', 'foo.json'],
      'configObject': 'foo'
    },
    plugins: [
      'stylus',
      'stylus-config'
    ]
  };

  describe('config output', function() {

    it('should include the config in scripts', function(done) {

      lib.pluginExec(undefined, 'scripts', config.modules.test, [], config, function(resources, context) {
        context.loadResource(resources[0], function(err, data) {
          if (err) {
            throw err;
          }

          data.content.should.eql('foo = {"$display":"black","value!":10};\n');<commit_msg>Allow more time for stylus-config tests<commit_after>var fs = require('fs'),
    fu = require('../../lib/fileUtil'),
    lib = require('../lib'),
    watch = require('../lib/watch');

describe('stylus-config plugin', function() {
  var readFileSync = fs.readFileSync,
      readFile = fs.readFile,
      statSync = fs.statSync;
  beforeEach(function() {
    fu.lookupPath('');

    this.stub(fs, 'readFileSync', function(path) {
      if (/file1\.styl|png$/.test(path) && !/functions(?:[\\\/]index)?.styl/.test(path)) {
        return '.test\n  display $display\n';
      } else if (/lumbar\.json$/.test(path)) {
        return JSON.stringify(config);
      } else if (/two\.json$/.test(path)) {
        return '{"$display": "red","value!":10}';
      } else if (/\.json$/.test(path)) {
        return '{"$display": "black"}';
      } else {
        return readFileSync.apply(this, arguments);
      }
    });
    this.stub(fs, 'readFile', function(path, callback) {
      process.nextTick(function() {
        try {
          callback(undefined, fs.readFileSync(path));
        } catch (err) {
          callback(err);
        }
      });
    });
    this.stub(fs, 'statSync', function(path) {
      if (!/(foo|two|lumbar|file1)\.(styl|png|json)$/.test(path) || /functions(?:[\\\/]index)?.styl/.test(path)) {
        return statSync.apply(this, arguments);
      }
    });
  });

  var config = {
    'modules': {
      'test': {
        'scripts': [{'stylus-config': true}],
        'styles': ['file1.styl']
      }
    },
    'styles': {
      'config': ['two.json', 'foo.json'],
      'configObject': 'foo'
    },
    plugins: [
      'stylus',
      'stylus-config'
    ]
  };

  describe('config output', function() {
    this.timeout(5000);

    it('should include the config in scripts', function(done) {

      lib.pluginExec(undefined, 'scripts', config.modules.test, [], config, function(resources, context) {
        context.loadResource(resources[0], function(err, data) {
          if (err) {
            throw err;
          }

          data.content.should.eql('foo = {"$display":"black","value!":10};\n');
{'fraction_non_alphanumeric': 0.20577014783023367, 'fraction_numerical': 0.004768717215069146, 'mean_word_length': 2.3857949959644875, 'pattern_counts': {'":': 10, '<': 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': '4486728', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1374, 'n_words': 235}