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

Function testStates

Web/WebAssembly/Testing/JavaScript/testStates.mjs:7–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const exepected_dependencies = [1, 2, 3, 5, 33, 35, 4, 6, 45, 48, 34, 12, 36, 37, 38, 39, 40, 41, 42, 43, 44, 7, 46, 49, 50, 51, 13, 8, 9, 11, 47, 10, 14, 15, 16, 17, 18, 21, 23, 26, 29, 32, 19, 20, 22, 24, 25, 27, 28, 30, 31]
6
7async function testStates() {
8 const dataDirectoryIndex = process.argv.indexOf("-D") + 1;
9 if (dataDirectoryIndex <= 0) {
10 throw new Error("Please provide path to a blobs file using -D");
11 }
12 const dataDirectory = process.argv[dataDirectoryIndex];
13 const blobs = JSON.parse(await readFile(path.join(dataDirectory, "Data", "WasmSceneManager", "scalar-bar-widget.blobs.json")));
14 const states = JSON.parse(await readFile(path.join(dataDirectory, "Data", "WasmSceneManager", "scalar-bar-widget.states.json")));
15 const vtkWASM = await globalThis.createVTKWASM({})
16 const remoteSession = new vtkWASM.vtkRemoteSession();
17 for (let i = 0; i < object_ids.length; ++i) {
18 const object_id = object_ids[i];
19 if (!remoteSession.registerState(states[object_id])) {
20 throw new Error(`Failed to register state at object_id=${object_id}`);
21 }
22 }
23 for (let hash in blobs) {
24 if (!remoteSession.registerBlob(hash, new Uint8Array(blobs[hash].bytes))) {
25 throw new Error(`Failed to register blob with hash=${hash}`);
26 }
27 }
28 remoteSession.updateObjectsFromStates();
29 const activeIds = remoteSession.getAllDependencies(0);
30 if (!(activeIds instanceof Uint32Array)) {
31 throw new Error("getAllDependencies did not return a Uint32Array");
32 }
33 if (activeIds.toString() != exepected_dependencies.toString()) {
34 throw new Error(`${activeIds} != ${exepected_dependencies}`);
35 }
36}
37
38const tests = [
39 {

Callers

nothing calls this directly

Calls 4

readFileFunction · 0.50
parseMethod · 0.45
joinMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected