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