Skip to content

Commit

Permalink
WIP: test(transform-io): add node tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Nov 5, 2024
1 parent be83be5 commit cd31863
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/transform-io/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"scripts": {
"start": "pnpm copyDemoAppAssets && vite",
"test": "echo \"Error: no test specified\"",
"test": "pnpm test:node",
"test:node": "ava",
"build": "pnpm build:tsc && pnpm build:browser:workerEmbedded && pnpm build:browser:workerEmbeddedMin && pnpm build:demo",
"build:browser:workerEmbedded": "esbuild --loader:.worker.js=dataurl --bundle --format=esm --outfile=./dist/bundle/index-worker-embedded.js ./src/index-worker-embedded.ts",
"build:browser:workerEmbeddedMin": "esbuild --minify --loader:.worker.js=dataurl --bundle --format=esm --outfile=./dist/bundle/index-worker-embedded.min.js ./src/index-worker-embedded.min.ts",
Expand All @@ -36,9 +37,10 @@
"itk-wasm": "workspace:^"
},
"devDependencies": {
"@itk-wasm/transform-io-build": "workspace:*",
"@itk-wasm/demo-app": "workspace:*",
"@itk-wasm/transform-io-build": "workspace:*",
"@types/node": "^20.2.5",
"ava": "^6.1.3",
"esbuild": "^0.19.8",
"shx": "^0.3.4",
"typescript": "^5.3.2",
Expand All @@ -48,5 +50,11 @@
"repository": {
"type": "git",
"url": "https://github.com/InsightSoftwareConsortium/ITK-Wasm"
},
"ava": {
"files": [
"test/node/**/*",
"!test/node/common.js"
]
}
}
7 changes: 7 additions & 0 deletions packages/transform-io/typescript/test/node/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import path from 'path'
import fs from 'fs'

export const testInputPath = path.resolve('..', 'test', 'data', 'input')
export const testBaselinePath = path.resolve('..', 'test', 'data', 'baseline')
export const testOutputPath = path.resolve('..', 'test', 'output', 'typescript')
fs.mkdirSync(testOutputPath, { recursive: true })
14 changes: 14 additions & 0 deletions packages/transform-io/typescript/test/node/hdf5-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from 'ava'
import path from 'path'

import { hdf5ReadTransformNode } from '../../dist/index-node.js'

import { testInputPath } from './common.js'

const testInputFilePath = path.join(testInputPath, 'LinearTransform.h5')

test('Test reading a HDF5 file', async t => {
const { couldRead, transform } = await hdf5ReadTransformNode(testInputFilePath)
t.true(couldRead)
console.log(transform)
})
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd31863

Please sign in to comment.