MCPcopy Create free account
hub / github.com/Kitware/VTK / testBlobs

Function testBlobs

Web/WebAssembly/Testing/JavaScript/testBlobs.mjs:4–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import path from "path";
3
4async function testBlobs() {
5 const dataDirectoryIndex = process.argv.indexOf("-D") + 1;
6 if (dataDirectoryIndex <= 0) {
7 throw new Error("Please provide path to a blobs file using -D");
8 }
9 const dataDirectory = process.argv[dataDirectoryIndex];
10 const blobs = JSON.parse(await readFile(path.join(dataDirectory, "Data", "WasmSceneManager", "simple.blobs.json")));
11 const vtkWASM = await globalThis.createVTKWASM({})
12 const remoteSession = new vtkWASM.vtkRemoteSession();
13
14 for (let hash in blobs) {
15 if (!remoteSession.registerBlob(hash, new Uint8Array(blobs[hash].bytes))) {
16 throw new Error(`Failed to register blob with hash=${hash}`);
17 }
18 }
19 for (let hash in blobs) {
20 const blob = remoteSession.getBlob(hash);
21 if (!(blob instanceof Uint8Array)) {
22 throw new Error(`getBlob did not return a Uint8Array for hash=${hash}`);
23 }
24 if (blob.toString() !== blobs[hash].bytes.toString()) {
25 throw new Error(`blob for hash=${hash} does not match registered blob.`);
26 }
27 }
28}
29
30const tests = [
31 {

Callers

nothing calls this directly

Calls 5

getBlobMethod · 0.80
readFileFunction · 0.50
parseMethod · 0.45
joinMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected