'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'
      }
    ];

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

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

    it('writes the files to rasterize at the right size', (done) => {
      RasterizeList({src: src, toRasterize: toRasterize}).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();
      });
    });
  });
});

@@ -528,16 +528,130 @@
 %7D%0A    %5D;
+%0A    let subject;%0A%0A    before(() =%3E %7B%0A      subject = RasterizeList(%7Bsrc: src, toRasterize: toRasterize%7D);%0A    %7D);
 %0A%0A    af
@@ -653,20 +653,16 @@
    after
-Each
 (() =%3E %7B
@@ -846,75 +846,15 @@
 ect(
-%0A        RasterizeList(%7Bsrc: src, toRasterize: toRasterize%7D)%0A      
+subject
 ).to
@@ -982,59 +982,15 @@
     
-RasterizeList(%7Bsrc: src, toRasterize: toRasterize%7D)
+subject
 .the

Update test to improve speed by only writing and unlinking files once