<commit_before>var fs = require('fs'),
    lib = require('./lib'),
    stylusImages = require('../');

function runTest(test, options, done) {
  stylusImages(test, options)
    .include(process.cwd() + '/test')
    .render(function(err, css) {
      // Timeout to prevent multiple errors in response to catch resend
      setTimeout(function() {
        if (err) {
          throw err;
        }

        done(css);
      }, 0);
    });
}

describe('multiple ouput', function() {
  fs.mkdir('/tmp/stylus-images', parseInt('0777', 8));

  it('should output a file for each resolution', function(done) {
    runTest(
      '.test\n'
      + '  background-image url("images/barrowLoRez.png")\n',

      {images: {resolutions: [0.5, 1, 2, 3]}},

      function(data) {
        function expected(density) {
          return '.test {\n'
              + '  background-image: url("' + (density >= 2 ? lib.HI_REZ_DATA : lib.LO_REZ_DATA) + '");\n'
              + '}\n';
        }
        data.should.eql({
          '0.5': expected(0.5),
          '1': expected(1),
          '2': expected(2),
          '3': expected(3)
        });

        done();
      });
  });

  it.skip('should copy files for each resolution', function(done) {
    // TODO : Setup a case where one resolution does not copy and the other does
  });
  it.skip('should merge files for each resolution', function(done) {
    // TODO : Setup a case where one resolution should merge the the other should not
  });
});<commit_msg>Multiple output copy tests<commit_after>var fs = require('fs'),
    lib = require('./lib'),
    stylusImages = require('../'),
    wrench = require('wrench');

function runTest(test, options, done) {
  stylusImages(test, options)
    .include(process.cwd() + '/test')
    .render(function(err, css) {
      // Timeout to prevent multiple errors in response to catch resend
      setTimeout(function() {
        if (err) {
          throw err;
        }

        done(css);
      }, 0);
    });
}

describe('multiple ouput', function() {
  before(function() {
    fs.mkdir('/tmp/stylus-images', parseInt('0777', 8));
  });
  after(function() {
    wrench.rmdirSyncRecursive('/tmp/stylus-images');
  });

  it('should output a file for each resolution', function(done) {
    runTest(
      '.test\n'
      + '  background-image url("images/barrowLoRez.png")\n',

      {images: {resolutions: [0.5, 1, 2, 3]}},

      function(data) {
        function expected(density) {
          return '.test {\n'
              + '  background-image: url("' + (density >= 2 ? lib.HI_REZ_DATA : lib.LO_REZ_DATA) + '");\n'
              + '}\n';
        }
        data.should.eql({
          '0.5': expected(0.5),
          '1': expected(1),
          '2': expected(2),
          '3': expected(3)
        });

        done();
      });
  });

  it('should copy files for each resolution', function(done) {
    runTest(
      '.test\n'
      + '  background-image url("images/barrowLoRez.png")\n',

      {images: {resolutions: [0.5, 1, 2, 3], limit: 115, copyFiles: true, outdir: '/tmp/stylus-images'}},

      function(data) {
        function expected(density) {
          return '.test {\n'
              + '  background-image: url("' + (density >= 2 ? lib.HI_REZ_DATA : 'images/barrowLoRez.png') + '");\n'
              + '}\n';
        }
        data.should.eql({
          '0.5': expected(0.5),
          '1': expected(1),
          '2': expected(2),
          '3': expected(3)
        });

        fs.statSync('/tmp/stylus-images/images/barrowLoRez.png').isFile().should.be.true;

        done();
      });
  });
  it.skip('should merge files for each resolution', function(done) {
    // TODO : Setup a case where one resolution should merge the the other should not
  });
});
{'fraction_non_alphanumeric': 0.17416777629826896, 'fraction_numerical': 0.01677762982689747, 'mean_word_length': 2.1616161616161618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5595532', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1204, 'n_words': 283}