<commit_before>// Algorythm should not change. Use fixtures to check.
//
'use strict';

const Canvas     = require('canvas');
const Image      = Canvas.Image;
const fs         = require('fs');
const path       = require('path');
const pica       = require('../');
const pixelmatch = require('pixelmatch');

const ppm        = require('./ppm');

const FIXTURES_DIRECTORY = path.join(__dirname, 'fixtures');
const OUTPUT_DIRECTORY   = path.join(__dirname, '..');

//
// Shim browser method
//
global.document = global.document || {};
global.document.createElement = global.document.createElement || function (name) {
  if (name === 'canvas') return new Canvas();
  throw new Error('createElement(' + name + ') not shimmed');
};


describe('Fixture resize', function () {

  it('.resizeCanvas() should be correct for the given fixture', function () {
    this.timeout(3000);

    let srcImage = new Image();

    srcImage.src = fs.readFileSync(path.join(FIXTURES_DIRECTORY, 'original.jpg'));

    let srcCanvas = new Canvas();

    srcCanvas.width = srcImage.width;
    srcCanvas.height = srcImage.height;

    let srcCtx = srcCanvas.getContext('2d');

    srcCtx.drawImage(srcImage, 0, 0);

    let fixtureImage = new Image();

    fixtureImage.src = fs.readFileSync(path.join(FIXTURES_DIRECTORY, 'resized.png'));

    let fixtureCanvas = new Canvas();
<commit_msg>Make node_canvas use more local<commit_after>// Algorythm should not change. Use fixtures to check.
//
'use strict';

const fs         = require('fs');
const path       = require('path');
const pica       = require('../');
const pixelmatch = require('pixelmatch');

const ppm        = require('./ppm');

const FIXTURES_DIRECTORY = path.join(__dirname, 'fixtures');
const OUTPUT_DIRECTORY   = path.join(__dirname, '..');


describe('Fixture resize', function () {

  it('.resizeCanvas() should be correct for the given fixture', function () {
    const Canvas     = require('canvas');
    const Image      = Canvas.Image;
    //
    // Shim browser method
    //
    global.document = global.document || {};
    global.document.createElement = global.document.createElement || function (name) {
      if (name === 'canvas') return new Canvas();
      throw new Error('createElement(' + name + ') not shimmed');
    };


    this.timeout(3000);

    let srcImage = new Image();

    srcImage.src = fs.readFileSync(path.join(FIXTURES_DIRECTORY, 'original.jpg'));

    let srcCanvas = new Canvas();

    srcCanvas.width = srcImage.width;
    srcCanvas.height = srcImage.height;

    let srcCtx = srcCanvas.getContext('2d');

    srcCtx.drawImage(srcImage, 0, 0);

    let fixtureImage = new Image();

    fixtureImage.src = fs.readFileSync(path.join(FIXTURES_DIRECTORY, 'resized.png'));

    let fixtureCanvas = new Canvas();

{'fraction_non_alphanumeric': 0.14721723518850988, 'fraction_numerical': 0.005026929982046679, 'mean_word_length': 3.4363057324840764, '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': '5864150', 'n_tokens_mistral': 856, 'n_tokens_neox': 811, 'n_words': 214}