<commit_before>'use strict';

const expect        = require('../../helpers/expect');
const fs            = require('fs');
const sizeOf        = require('image-size');

const RasterizeList = require('../../../src/utils/rasterize-list');

describe('RasterizeList', function() {
  // Hitting the file system is slow
  this.timeout(0);

  context('when src and toRasterize', () => {
    const src = 'node-tests/fixtures/icon.svg';
    const toRasterize = [
      {
        size: 60,
        name: 'icon-60',
        path: 'tmp/icon-60.png'
      }
    ];
    let subject;

    before(() => {
      subject = RasterizeList({src: src, toRasterize: toRasterize});
    });

    after(() => {
      toRasterize.forEach((rasterize) => {
        fs.unlinkSync(rasterize.path);
      });
    });

    it('returns a promise that resolves to an array', (done) => {
      expect(subject).to.eventually.be.a('array').notify(done);
    });

    it('writes the files to rasterize at the right size', (done) => {
      subject.then(() => {
        toRasterize.forEach((rasterize) => {
          expect(fs.existsSync(rasterize.path)).to.equal(true);
          expect(sizeOf(rasterize.path).width).to.equal(rasterize.size);
          expect(sizeOf(rasterize.path).height).to.equal(rasterize.size);
        });
        done();
      });
    });
  });
});<commit_msg>fix(rasterize-list): Update test to not hang on failed promise-dependant expecation<commit_after>'use strict';

const expect        = require('../../helpers/expect');
const fs            = require('fs');
const sizeOf        = require('image-size');

const RasterizeList = require('../../../src/utils/rasterize-list');

describe('RasterizeList', function() {
  // Hitting the file system is slow
  this.timeout(0);

  context('when src and toRasterize', () => {
    const src = 'node-tests/fixtures/icon.svg';
    const toRasterize = [
      {
        size: 60,
        name: 'icon-60',
        path: 'tmp/icon-60.png'
      }
    ];
    let subject;

    before(() => {
      subject = RasterizeList({src: src, toRasterize: toRasterize});
    });

    after(() => {
      toRasterize.forEach((rasterize) => {
        fs.unlinkSync(rasterize.path);
      });
    });

    it('returns a promise that resolves to an array', (done) => {
      expect(subject).to.eventually.be.a('array').notify(done);
    });

    it('writes the files to rasterize at the right size', (done) => {
      subject.then(() => {
        try {
          toRasterize.forEach((rasterize) => {
            expect(fs.existsSync(rasterize.path)).to.equal(true);
            expect(sizeOf(rasterize.path).width).to.equal(rasterize.size);
            expect(sizeOf(rasterize.path).height).to.equal(rasterize.size);
          });
          done();
        } catch(e) {
          done(e);
        }
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.1771347918136909, 'fraction_numerical': 0.004940014114326041, 'mean_word_length': 2.347107438016529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '123729', 'n_tokens_mistral': 923, 'n_tokens_neox': 904, 'n_words': 162}