28 lines
1.7 KiB
TypeScript
28 lines
1.7 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { createInspection } from '../src/facade/inspection'
|
|
|
|
const shape = { id: 'box', label: 'Box', volume: 120, area: 148, structuralValid: true, bounds: { min: [0, 0, 0] as [number, number, number], max: [4, 5, 6] as [number, number, number] }, topoRefs: [{ persistentId: 'Face1', kind: 'face' as const, status: 'stable' as const }] }
|
|
|
|
test('inspection measures points, vectors and registered shape values', () => {
|
|
const inspection = createInspection()
|
|
inspection.registerShape(shape)
|
|
assert.equal(inspection.measureDistance('distance', [0, 0, 0], [3, 4, 0]).value, 5)
|
|
assert.equal(inspection.measureAngle('angle', [1, 0, 0], [0, 1, 0]).value, 90)
|
|
assert.equal(inspection.measureShape('volume', 'box', 'volume').value, 120)
|
|
assert.equal(inspection.measureShape('area', 'box', 'area').unit, 'mm2')
|
|
assert.equal(inspection.measureDeviation('deviation', 10, 10.01, 0.02).status, 'resolved')
|
|
assert.equal(inspection.section('box', 3).area, 20)
|
|
assert.deepEqual(inspection.topoRefReport('box'), { total: 1, stable: 1, unresolved: [] })
|
|
assert.equal(inspection.exportCsv().trim().split('\n').length, 6)
|
|
})
|
|
|
|
test('inspection reports missing dependencies and isolates snapshots', () => {
|
|
const inspection = createInspection()
|
|
inspection.registerShape({ ...shape, id: 'child', dependencies: ['missing'] })
|
|
assert.deepEqual(inspection.checkDependencies(), ['child->missing'])
|
|
const snapshot = inspection.snapshot(); snapshot.shapes[0].bounds.min[0] = 99
|
|
assert.equal(inspection.snapshot().shapes[0]?.bounds.min[0], 0)
|
|
assert.equal(inspection.measureAngle('invalid', [0, 0, 0], [1, 0, 0]).status, 'invalid')
|
|
})
|