<commit_before>// Load in dependencies
var assert = require('assert');
var spritesmithUtils = require('./utils/spritesmith');

/**
 * Define our main test function
 * @param {Object} params Container for paramters
 * @param {Object} params.engine Spritemith engine to test
 * @param {String} params.engineName Name of engine to test
 * @param {Object} [params.flags] Options to enable/disable tests
 */
function spritesmithEngineTest(params) {
  // Assert and localize parameters
  assert(params, '`params` was not provided to `spritesmith-engine-test`');
  var engine = params.engine;
  assert(engine, '`params.engine` was not provided to `spritesmith-engine-test`');
  assert(params.engineName, '`params.engineName` was not provided to `spritesmith-engine-test`, please provide one (e.g. \'phantomjssmith\')');

  // Define our tests
  describe(params.engineName, function () {
    describe('interpretting an image file', function () {
      spritesmithUtils.interpretImages([config.singleImage]);

      it('gathers statistics on an image file', function () {
        // Fallback images and grab first one
        var imgs = this.imgs || [];
        var img = imgs[0];

        // Assert against image
        expect(img).to.have.property('height', 50);
        expect(img).to.have.property('width', 50);
      });
    });

    describe('parsing multiple images', function () {
      spritesmithUtils.interpretImages([config.multipleImages]);

      describe('rendering them into a canvas', function () {
        spritesmithUtils.renderCanvas({
          width: 100,
          height: 300,
          coordinateArr: [
            {x: 0, y: 0},
            {x: 0, y: 50},
            {x: 0, y: 100}
          ],
          exportParams: {
            format: 'png'
          }
        });

        it('can output an image', function () {

        });

      });
    });
    describe('interpretting a ridiculous amount of images', function () {
      describe('rendering them into a canvas', function () {
        it('does not crash', function () {

        });
        it('returns an image', function () {

        });
      });
    });

    // DEV: This is testing an edge case of phantomjssmith
    describe('interpretting a large image', function () {
      it('gathers proper image size', function () {
<commit_msg>Realized that we should start using `get-pixels` now<commit_after>// Load in dependencies
var assert = require('assert');
var spritesmithUtils = require('./utils/spritesmith');

/**
 * Define our main test function
 * @param {Object} params Container for paramters
 * @param {Object} params.engine Spritemith engine to test
 * @param {String} params.engineName Name of engine to test
 * @param {Object} [params.flags] Options to enable/disable tests
 */
function spritesmithEngineTest(params) {
  // Assert and localize parameters
  assert(params, '`params` was not provided to `spritesmith-engine-test`');
  var engine = params.engine;
  assert(engine, '`params.engine` was not provided to `spritesmith-engine-test`');
  assert(params.engineName, '`params.engineName` was not provided to `spritesmith-engine-test`, please provide one (e.g. \'phantomjssmith\')');

  // Define our tests
  describe(params.engineName, function () {
    describe('interpretting an image file', function () {
      spritesmithUtils.interpretImages([config.singleImage]);

      it('gathers statistics on an image file', function () {
        // Fallback images and grab first one
        var imgs = this.imgs || [];
        var img = imgs[0];

        // Assert against image
        expect(img).to.have.property('height', 50);
        expect(img).to.have.property('width', 50);
      });
    });

    describe('parsing multiple images', function () {
      spritesmithUtils.interpretImages([config.multipleImages]);

      describe('rendering them into a canvas', function () {
        spritesmithUtils.renderCanvas({
          width: 100,
          height: 300,
          coordinateArr: [
            {x: 0, y: 0},
            {x: 0, y: 50},
            {x: 0, y: 100}
          ],
          exportParams: {
            format: 'png'
          }
        });

        it('can output an image', function () {
          // Assert the actual image is the same expected
          var actualImage = this.result;
          var matchesAnImage = false;

          // Allow for debugging
          if (process.env.TEST_DEBUG) {
            fs.writeFileSync('debug.png', actualImage, 'binary');
          }

          // TODO: Visit using `get-pixels`
          // ANTI-PATTERN: Looping over set without identifiable lines for stack traces
          this.expectedFilepaths.forEach(function testAgainstExpected (filepath) {
            if (!matchesAnImage) {
              var expectedImage = fs.readFileSync(filepath, 'binary');
              matchesAnImage = actualImage === expectedImage;
            }
          });

          expect(matchesAnImage).to.equal(true);
        });
      });
    });
    describe('interpretting a ridiculous amount of images', function () {
      describe('rendering them into a canvas', function () {
        it('does not crash', function () {

        });
        it('returns an image', function () {

        });
      });
    });

    // DEV: This is testing an edge case of phantomjssmith
    describe('interpretting a large image', function () {
      it('gathers proper image size', function () {

{'fraction_non_alphanumeric': 0.12661260597124954, 'fraction_numerical': 0.007371913011426466, 'mean_word_length': 2.524025974025974, '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': '5403234', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1440, 'n_words': 440}