Scene Graph unit tests move to packages/scene-graph/tests with a package-local assert helper and test type-checking; five Core- and fig-owned tests move to their owners' engine homes. check:test-homes rejects any new test under tests/engine against a reviewed baseline so the migration debt only shrinks.
13 lines
405 B
TypeScript
13 lines
405 B
TypeScript
import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
|
|
|
|
export function expectDefined<T>(value: T | null | undefined, label = 'value'): NonNullable<T> {
|
|
if (value == null) {
|
|
throw new Error(`${label} was expected to be defined`)
|
|
}
|
|
return value
|
|
}
|
|
|
|
export function getNodeOrThrow(graph: SceneGraph, id: string): SceneNode {
|
|
return expectDefined(graph.getNode(id), `node ${id}`)
|
|
}
|