|
1 | 1 | import test from 'tape' |
2 | 2 | import axios from 'axios' |
3 | 3 |
|
4 | | -test('Loading an image file and displaying its contents', (t) => { |
| 4 | +test('Load an image file and display its contents', (t) => { |
5 | 5 | const expectedOutput = `{ |
6 | 6 | "imageType": { |
7 | 7 | "dimension": 2, |
@@ -44,6 +44,51 @@ test('Loading an image file and displaying its contents', (t) => { |
44 | 44 | document.body.appendChild(outputTextArea) |
45 | 45 | processFile(event) |
46 | 46 | .then(function () { |
| 47 | + outputTextArea.remove(outputTextArea) |
| 48 | + t.equal(outputTextArea.textContent, expectedOutput, 'Text area matches expected output') |
| 49 | + t.end() |
| 50 | + }) |
| 51 | + }) |
| 52 | +}) |
| 53 | + |
| 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 | + processFile(event) |
| 90 | + .then(function () { |
| 91 | + outputTextArea.remove() |
47 | 92 | t.equal(outputTextArea.textContent, expectedOutput, 'Text area matches expected output') |
48 | 93 | t.end() |
49 | 94 | }) |
|
0 commit comments