<commit_before>import test from 'tape'
import axios from 'axios'

import { outputFileInformation } from '../src/index'

test('Load an image file and display its contents', (t) => {
  const expectedOutput = `{
    "imageType": {
        "dimension": 2,
        "componentType": "uint8",
        "pixelType": "Scalar",
        "components": 1
    },
    "name": "Image",
    "origin": [
        0,
        0
    ],
    "spacing": [
        1,
        1
    ],
    "direction": "1,0,0,1...",
    "size": [
        100,
        100
    ],
    "metadata": {},
    "data": "0,0,0,0,0,0..."
}`
  const imageURL = 'https://data.kitware.com/api/v1/file/57b76d848d777f10f269bcdf/download'
  return axios.get(imageURL, { responseType: 'blob' })
    .then((response) => {
      const testFile = new window.File([response.data], 'BinaryImageWithVariousShapes01.png')
      // mock the event
      const event = { target: { files: [testFile] } }
      const outputTextArea = document.createElement('textarea')
      document.body.appendChild(outputTextArea)
      outputFileInformation(outputTextArea, event)
        .then(function () {
          t.equal(outputTextArea.textContent, expectedOutput)
          t.end()
        })
    })
})

test('Load a mesh file and display its contents', (t) => {
  const expectedOutput = `{
    "mt": {
        "dimension": 3,
        "pointComponentType": "float32",
        "pointPixelComponentType": "float32",
        "pointPixelType": "Scalar",
        "pointPixelComponents": 0,
        "cellComponentType": "uint32",
        "cellPixelComponentType": "float32",
        "cellPixelType": "Scalar",
        "cellPixelComponents": 0
    },
    "name": "Mesh",
    "meshType": {
        "dimension": 3,
        "pointComponentType": "float32",
        "pointPixelComponentType": "float32",
        "pointPixelType": "Scalar",
        "pointPixelComponents": 0,
        "cellComponentType": "uint32",
        "cellPixelComponentType": "float32",
        "cellPixelType": "Scalar",
        "cellPixelComponents": 0
    },
    "numberOfPoints": 2903,
    "points": "3.716360092163086,2.3433899879455566,0,4.126560211181641,0.6420270204544067,0...",
    "numberOfPointPixels": 0,
    "pointData": null,
    "numberOfCells": 3263,
    "cellBufferSize": 18856,
    "cells": "4,4,250,251,210,252...",
    "numberOfCellPixels": 0,
    "cellData": null
}`

  const meshURL = 'https://data.kitware.com/api/v1/file/5c72abb18d777f072b610e69/download'
  return axios.get(meshURL, { responseType: 'blob' })
    .then((response) => {
      const testFile = new window.File([response.data], 'cow.vtk')
      // mock the event
      const event = { target: { files: [testFile] } }
      const outputTextArea = document.createElement('textarea')
      document.body.appendChild(outputTextArea)
      outputFileInformation(outputTextArea, event)
        .then(function () {
          outputTextArea.remove()
          t.equal(outputTextArea.textContent, expectedOutput, 'Text area matches expected output')
          t.end()
        })
    })
})<commit_msg>fix(WebPackExample): Improve test output comparison<commit_after>import test from 'tape'
import axios from 'axios'

import { outputFileInformation } from '../src/index'

test('Load an image file and display its contents', (t) => {
  const expectedOutput = `{
    "imageType": {
        "dimension": 2,
        "componentType": "uint8",
        "pixelType": "Scalar",
        "components": 1
    },
    "origin": [
        0,
        0
    ],
    "spacing": [
        1,
        1
    ],
    "direction": "1,0,0,1...",
    "size": [
        100,
        100
    ],
    "data": "0,0,0,0,0,0..."
}`
  const imageURL = 'https://data.kitware.com/api/v1/file/57b76d848d777f10f269bcdf/download'
  return axios.get(imageURL, { responseType: 'blob' })
    .then((response) => {
      const testFile = new window.File([response.data], 'BinaryImageWithVariousShapes01.png')
      // mock the event
      const event = { target: { files: [testFile] } }
      const outputTextArea = document.createElement('textarea')
      document.body.appendChild(outputTextArea)
      outputFileInformation(outputTextArea, event)
        .then(function () {
          const expectedJSON = JSON.parse(expectedOutput)
          const outputJSON = JSON.parse(outputTextArea.textContent)
          t.deepEqual(expectedJSON, outputJSON, 'Output image comparison')
          t.end()
        })
    })
})

test('Load a mesh file and display its contents', (t) => {
  const expectedOutput = `{
    "mt": {
        "dimension": 3,
        "pointComponentType": "float32",
        "pointPixelComponentType": "float32",
        "pointPixelType": "Scalar",
        "pointPixelComponents": 0,
        "cellComponentType": "uint32",
        "cellPixelComponentType": "float32",
        "cellPixelType": "Scalar",
        "cellPixelComponents": 0
    },
    "name": "Mesh",
    "meshType": {
        "dimension": 3,
        "pointComponentType": "float32",
        "pointPixelComponentType": "float32",
        "pointPixelType": "Scalar",
        "pointPixelComponents": 0,
        "cellComponentType": "uint32",
        "cellPixelComponentType": "float32",
        "cellPixelType": "Scalar",
        "cellPixelComponents": 0
    },
    "numberOfPoints": 2903,
    "points": "3.716360092163086,2.3433899879455566,0,4.126560211181641,0.6420270204544067,0...",
    "numberOfPointPixels": 0,
    "pointData": null,
    "numberOfCells": 3263,
    "cellBufferSize": 18856,
    "cells": "4,4,250,251,210,252...",
    "numberOfCellPixels": 0,
    "cellData": null
}`

  const meshURL = 'https://data.kitware.com/api/v1/file/5c72abb18d777f072b610e69/download'
  return axios.get(meshURL, { responseType: 'blob' })
    .then((response) => {
      const testFile = new window.File([response.data], 'cow.vtk')
      // mock the event
      const event = { target: { files: [testFile] } }
      const outputTextArea = document.createElement('textarea')
      document.body.appendChild(outputTextArea)
      outputFileInformation(outputTextArea, event)
        .then(function () {
          outputTextArea.remove()
          const expectedJSON = JSON.parse(expectedOutput)
          const outputJSON = JSON.parse(outputTextArea.textContent)
          t.deepEqual(expectedJSON, outputJSON, 'Output mesh comparison')
          t.end()
        })
    })
})
{'fraction_non_alphanumeric': 0.14903317088508097, 'fraction_numerical': 0.055651627102656816, 'mean_word_length': 2.7291910902696364, 'pattern_counts': {'":': 82, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '219654', 'n_tokens_mistral': 2196, 'n_tokens_neox': 1996, 'n_words': 384}