Something went wrong. Try again.
[PRE-ALPHA] an open source web-based 2D/3D graphing calculator cartesium.org
Something went wrong. Try again.
TypeScript
at mathquill
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import { describe, expect, it } from 'vitest';
import { normalizeWasmScene, normalizeWasmScene3d } from './scene-normalization';import type { RenderScene2d } from './types';
describe('Wasm scene normalization', () => { it('converts serialized maps into records addressable by expression ID', () => { const viewport = { x_min: -1, x_max: 1, y_min: -1, y_max: 1, width: 100, height: 100 };
const scene = normalizeWasmScene({ viewport, coverage: viewport, layers: [], diagnostics: [], variables: [], expression_roles: new Map([ ['variable', 'variable'], ['function', 'function'] ]), model_revisions: new Map([['plot', 7]]) });
expect(scene.expression_roles).toEqual({ variable: 'variable', function: 'function' }); expect(scene.model_revisions.plot).toBe(7); });
it('preserves already-normalized records', () => { const viewport = { x_min: -1, x_max: 1, y_min: -1, y_max: 1, width: 100, height: 100 };
const scene: RenderScene2d = { viewport, coverage: viewport, layers: [], diagnostics: [], variables: [], expression_roles: { plot: 'plot' }, model_revisions: { plot: 2 } };
expect(normalizeWasmScene(scene)).toMatchObject(scene); });
it('normalizes 3D map metadata before revision checks', () => { const scene = normalizeWasmScene3d({ bounds: { x_min: -1, x_max: 1, y_min: -1, y_max: 1, z_min: -1, z_max: 1 }, resources: [], diagnostics: [], variables: [], expression_roles: new Map([['gyroid', 'plot']]), model_revisions: new Map([['gyroid', 9]]) });
expect(scene.expression_roles).toEqual({ gyroid: 'plot' }); expect(scene.model_revisions).toEqual({ gyroid: 9 }); });});