diff --git a/packages/transform-io/typescript/test/node/hdf5-test.js b/packages/transform-io/typescript/test/node/hdf5-test.js index d4945d180..3fbeb942c 100644 --- a/packages/transform-io/typescript/test/node/hdf5-test.js +++ b/packages/transform-io/typescript/test/node/hdf5-test.js @@ -1,11 +1,22 @@ import test from "ava"; import path from "path"; -import { hdf5ReadTransformNode } from "../../dist/index-node.js"; +import { + hdf5ReadTransformNode, + hdf5WriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.h5"); +const testOutputFilePath = path.join( + testOutputPath, + "hdf5-test-write-LinearTransform.h5" +); test("Test reading a HDF5 file", async (t) => { const { couldRead, transform } = await hdf5ReadTransformNode( @@ -14,3 +25,21 @@ test("Test reading a HDF5 file", async (t) => { t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing a HDF5 transform file", async (t) => { + const { couldRead, transform } = await hdf5ReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await hdf5WriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await hdf5ReadTransformNode(testInputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/packages/transform-io/typescript/test/node/mat-test.js b/packages/transform-io/typescript/test/node/mat-test.js index 105f4082d..9ddd9a45a 100644 --- a/packages/transform-io/typescript/test/node/mat-test.js +++ b/packages/transform-io/typescript/test/node/mat-test.js @@ -1,11 +1,22 @@ import test from "ava"; import path from "path"; -import { matReadTransformNode } from "../../dist/index-node.js"; +import { + matReadTransformNode, + matWriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.mat"); +const testOutputFilePath = path.join( + testOutputPath, + "mat-test-write-LinearTransform.mat" +); test("Test reading a .mat file", async (t) => { const { couldRead, transform } = await matReadTransformNode( @@ -14,3 +25,21 @@ test("Test reading a .mat file", async (t) => { t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing .mat transform file", async (t) => { + const { couldRead, transform } = await matReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await matWriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await matReadTransformNode(testInputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +}); diff --git a/packages/transform-io/typescript/test/node/txt-test.js b/packages/transform-io/typescript/test/node/txt-test.js index 7f2eab445..7c8257f97 100644 --- a/packages/transform-io/typescript/test/node/txt-test.js +++ b/packages/transform-io/typescript/test/node/txt-test.js @@ -1,16 +1,45 @@ import test from "ava"; import path from "path"; -import { txtReadTransformNode } from "../../dist/index-node.js"; +import { + txtReadTransformNode, + txtWriteTransformNode, +} from "../../dist/index-node.js"; -import { testInputPath, verifyTestLinearTransform } from "./common.js"; +import { + testInputPath, + testOutputPath, + verifyTestLinearTransform, +} from "./common.js"; const testInputFilePath = path.join(testInputPath, "LinearTransform.txt"); +const testOutputFilePath = path.join( + testOutputPath, + "txt-test-write-LinearTransform.txt" +); -test("Test reading a Insight Legacy TXT transform file", async (t) => { +test("Test reading an Insight Legacy TXT transform file", async (t) => { const { couldRead, transform } = await txtReadTransformNode( testInputFilePath ); t.true(couldRead); verifyTestLinearTransform(t, transform); }); + +test("Test writing an Insight Legacy TXT transform file", async (t) => { + const { couldRead, transform } = await txtReadTransformNode( + testInputFilePath + ); + t.true(couldRead); + + const { couldWrite } = await txtWriteTransformNode( + transform, + testOutputFilePath + ); + t.true(couldWrite); + + const { couldRead: couldReadBack, transform: transformBack } = + await txtReadTransformNode(testInputFilePath); + t.true(couldReadBack); + verifyTestLinearTransform(t, transformBack); +});