@@ -3,7 +3,7 @@ import axios from 'axios'
33
44import { outputFileInformation } from '../src/index'
55
6- test ( 'Loading an image file and displaying its contents' , ( t ) => {
6+ test ( 'Load an image file and display its contents' , ( t ) => {
77 const expectedOutput = `{
88 "imageType": {
99 "dimension": 2,
@@ -51,3 +51,46 @@ test('Loading an image file and displaying its contents', (t) => {
5151 } )
5252 } )
5353} )
54+
55+ test ( 'Load a mesh file and display its contents' , ( t ) => {
56+ const expectedOutput = `{
57+ "meshType": {
58+ "dimension": 3,
59+ "pointComponentType": "float",
60+ "pointPixelComponentType": null,
61+ "pointPixelType": 1,
62+ "pointPixelComponents": 0,
63+ "cellComponentType": "uint32_t",
64+ "cellPixelComponentType": null,
65+ "cellPixelType": 1,
66+ "cellPixelComponents": 0
67+ },
68+ "name": "Mesh",
69+ "numberOfPoints": 2903,
70+ "points": "3.716360092163086,2.3433899879455566,0,4.126560211181641,0.6420270204544067,0...",
71+ "numberOfPointPixels": 0,
72+ "pointData": null,
73+ "numberOfCells": 3263,
74+ "cells": "4,4,250,251,210,252...",
75+ "numberOfCellPixels": 0,
76+ "cellData": null,
77+ "cellBufferSize": 18856,
78+ "numberofPointPixels": 0,
79+ "numberofCellPixels": 0
80+ }`
81+ const meshURL = 'https://data.kitware.com/api/v1/file/5c72abb18d777f072b610e69/download'
82+ return axios . get ( meshURL , { responseType : 'blob' } )
83+ . then ( ( response ) => {
84+ const testFile = new window . File ( [ response . data ] , 'cow.vtk' )
85+ // mock the event
86+ const event = { target : { files : [ testFile ] } }
87+ const outputTextArea = document . createElement ( 'textarea' )
88+ document . body . appendChild ( outputTextArea )
89+ outputFileInformation ( outputTextArea , event )
90+ . then ( function ( ) {
91+ outputTextArea . remove ( )
92+ t . equal ( outputTextArea . textContent , expectedOutput , 'Text area matches expected output' )
93+ t . end ( )
94+ } )
95+ } )
96+ } )
0 commit comments