<commit_before>const { resolve } = require('path')
const test = require('tape')
const { readFile, rm } = require('fildes-extra')
const minifyImages = require('../index.js')
const { getSize } = require('../size.js')

test('cleanup', t => {
  rm(resolve(__dirname, 'build'))
  .then(() => t.end())
  .catch(err => t.fail(err))
})

test('compress', t => {
  const input = resolve(__dirname, 'fixtures/palette.png')
  const output = resolve(__dirname, 'build/palette.png')

  minifyImages({ input, output })
  .then(() => Promise.all([
    readFile(input).then(data => Buffer.byteLength(data)),
    readFile(output).then(data => Buffer.byteLength(data))
  ]))
  .then(sizes => {
    t.ok(sizes[1] < sizes[0], 'size of compressed image is smaller')
  })
  .then(() => t.end())
  .catch(err => t.fail(err))
})


test('resize and compress', t => {
  const input = resolve(__dirname, 'fixtures/palette.png')
  const output = resolve(__dirname, 'build/palette-small.png')

  minifyImages({ input, output, width: 10 })
  .then(() => Promise.all([
    readFile(input).then(data => getSize(data)),
    readFile(output).then(data => getSize(data))
  ]))
  .then(sizes => {
    t.ok(sizes[1].width < sizes[0].width, 'width of resized image is smaller')
    t.ok(sizes[1].height < sizes[0].height, 'height of resized image is smaller')
  })
  .then(() => t.end())
  .catch(err => t.fail(err))
})<commit_msg>generates a bigger image<commit_after>const { resolve } = require('path')
const test = require('tape')
const { readFile, rm } = require('fildes-extra')
const minifyImages = require('../index.js')
const { getSize } = require('../size.js')

test('cleanup', t => {
  rm(resolve(__dirname, 'build'))
  .then(() => t.end())
  .catch(err => t.fail(err))
})

test('compress', t => {
  const input = resolve(__dirname, 'fixtures/palette.png')
  const output = resolve(__dirname, 'build/palette.png')

  minifyImages({ input, output })
  .then(() => Promise.all([
    readFile(input).then(data => Buffer.byteLength(data)),
    readFile(output).then(data => Buffer.byteLength(data))
  ]))
  .then(sizes => {
    t.ok(sizes[1] < sizes[0], 'size of compressed image is smaller')
  })
  .then(() => t.end())
  .catch(err => t.fail(err))
})


test('resize and compress', t => {
  const input = resolve(__dirname, 'fixtures/palette.png')
  const output = resolve(__dirname, 'build/palette-small.png')

  minifyImages({ input, output, width: 48 })
  .then(() => Promise.all([
    readFile(input).then(data => getSize(data)),
    readFile(output).then(data => getSize(data))
  ]))
  .then(sizes => {
    t.ok(sizes[1].width < sizes[0].width, 'width of resized image is smaller')
    t.ok(sizes[1].height < sizes[0].height, 'height of resized image is smaller')
  })
  .then(() => t.end())
  .catch(err => t.fail(err))
})
{'fraction_non_alphanumeric': 0.20894454382826474, 'fraction_numerical': 0.005724508050089445, 'mean_word_length': 4.083636363636364, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, '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': '3587948', 'n_tokens_mistral': 979, 'n_tokens_neox': 962, 'n_words': 203}