← All packages

@searsuite/sear-assembly-test

Reusable test platforms, render contexts, and editor fixtures for package consumers.

Create a test Sheet

interfaceTestPluginRegistration

Test support contract for TestPluginRegistration.

interfaceTestProviderOverride

Test support contract for TestProviderOverride.

interfaceTestSheetCell

Test support contract for TestSheetCell.

interfaceTestSheetDataOptions

Test support contract for TestSheetDataOptions.

functioncreateTestSheet
createTestSheet(options?: CreateTestSheetOptions): TestSheetHarness

Builds the smallest real Sheet runtime that includes the render pipeline. Browser and scheduling boundaries are replaced with deterministic test implementations.

functionreplace
replace<T>(token: symbol, instance: T): TestProviderOverride

Replaces a binding after default test registrations and before the core resolves.

Test host adapters

classRecordingRenderContext
class RecordingRenderContext extends RenderContext

RenderContext implementation that records drawing calls without Canvas pixels.

constructorRecordingRenderContext(): RecordingRenderContext
propertyreadonly calls: RenderCall[]

Recorded render calls captured by RecordingRenderContext.

methodaddClickEventListener(callBack: (event: EventWithOffset): void): void

Adds the click event listener.

methodaddEventListener(type: string, callBack: (event: EventWithOffset): void): (): void

Adds the event listener.

methodaddMouseDownEventListener(callBack: (event: EventWithOffset): void): void

Adds the mouse down event listener.

methodaddMouseMoveEventListener(callBack: (event: EventWithOffset): void): void

Adds the mouse move event listener.

methodaddMouseUpEventListener(callBack: (event: EventWithOffset): void): void

Adds the mouse up event listener.

methodaddResizeListener(_callBack: (): void): void

Adds the resize listener.

methodbeginPath(): void

Begins a recorded vector path.

methodclearRect(x: number, y: number, width: number, height: number): void

Records a rectangular clear operation.

methodclip(): void

Clips subsequent recorded operations to the current path.

methodcloneNode(): RenderContext

Creates an independent copy of a recorded render node.

methodclosePath(): void

Closes the current recorded vector path.

methodcreateHitNode(): RenderContext

Creates the hit node.

methoddrawImage
drawImage(image: unknown, x: number, y: number): void drawImage(image: unknown, x: number, y: number, width: number, height: number): void drawImage(image: unknown, x: number, y: number, width: number, height: number, sx: number, sy: number, sWidth: number, sHeight: number): void

Records an image draw operation using the supplied source and bounds.

methodfill(): void

Fills the current path or exposes the node fill paint, depending on the render contract.

methodfillText(text: string, x: number, y: number, maxWidth?: number): void

Records text painting at the supplied position.

methodgetAttribute(name: string): string

Returns the attribute.

methodgetImageData(_x: number, _y: number, _width: number, _height: number): { data: [number, number, number, number][]; height: number; width: number }

Returns the image data.

methodgetLineWidth(): number

Returns the line width.

methodgetMaxLineWidth(): number

Returns the max line width.

methodgetRasterScale(): number

Returns the raster scale.

methodgetRenderTarget(): object

Returns the render target.

methodgetRoot(): EventTarget

Returns the root.

methodgetViewScale(): number

Returns the view scale.

methodinitialize(_scale?: number): void

Initializes the recording context for a render target.

methodlineTo(x: number, y: number): void

Adds a line segment to the current recorded path.

methodmeasureText(text: string): { fontAscent?: number; fontDescent?: number; height: number; width: number }

Measures text with the recording context's configured metrics.

methodmoveTo(x: number, y: number): void

Moves the current recorded path without drawing a segment.

methodputImageData(imageData: RenderImageData, x: number, y: number): void

Records raw pixel data at the supplied position.

methodrect(x: number, y: number, width: number, height: number): void

Adds a rectangle to the current recorded path.

methodremoveClickEventListener(callBack: (event: EventWithOffset): void): void

Removes the click event listener.

methodremoveMouseDownEventListener(callBack: (event: EventWithOffset): void): void

Removes the mouse down event listener.

methodremoveMouseMoveEventListener(callBack: (event: EventWithOffset): void): void

Removes the mouse move event listener.

methodremoveMouseUpEventListener(callBack: (event: EventWithOffset): void): void

Removes the mouse up event listener.

methodremoveResizeListener(): void

Removes the resize listener.

methodresetTransform(): void

Restores the recorded transform to the identity matrix.

methodresize(width: number, height: number, scale?: number): void

Resizes the render target and invalidates dependent frame state.

methodrestore(): void

Restores the most recently saved render state.

methodsave(): void

Pushes the current render state onto the recording stack.

methodsetAttribute(name: string, value: string): void

Updates the attribute.

methodsetFillStyle(fillStyle: RenderPaint): void

Updates the fill style.

methodsetFont(font: string): void

Updates the font.

methodsetLineDash(segments: number[]): void

Updates the line dash.

methodsetLineWidth(width: number): void

Updates the line width.

methodsetStrokeStyle(strokeStyle: RenderPaint): void

Updates the stroke style.

methodsetTransform(a: number, b: number, c: number, d: number, e: number, f: number): void

Updates the transform.

methodsetViewScale(scale: number): void

Updates the view scale.

methodstroke(): void

Strokes the current recorded path.

methodstrokeRect(x: number, y: number, width: number, height: number): void

Records a stroked rectangle operation.

methodtranslate(x: number, y: number): void

Offsets subsequent recorded operations by the supplied vector.

Inherited members 11

Inherited from RenderContext.

classTestPlatform
class TestPlatform extends Platform

Deterministic Platform implementation for harnesses and integration tests.

constructorTestPlatform(): TestPlatform
methodaddEventListener(_target: unknown, _type: string, _listener: (event: unknown): void): (): void

Registers a host event listener and returns an idempotent disposer.

methodcancelAnimationFrame(handle: number): void

Cancels a previously scheduled host animation frame.

methodclearInterval(handle: number): void

Cancels a repeating host timer.

methodclearTimeout(handle: number): void

Cancels a one-shot host timer.

methodcreateId(prefix?: string): string

Creates a deterministic test identifier.

methodcurrentDateTime(): number

Returns the test host wall-clock time as Unix milliseconds.

methoddestroy(): void

Releases resources owned by TestPlatform.

methodflush(): void

Runs all pending one-shot callbacks once, in creation order.

methodnow(): number

Returns the current test platform time.

methodobserveResize(_target: unknown, _callback: (size: { height: number; width: number }): void): (): void

Observes host-view size changes and returns an idempotent disposer.

methodqueueMicrotask(callback: (): void): void

Queues a microtask in the test platform.

methodreadViewOffset(_target: unknown): PlatformViewOffset

Test targets have no host-space offset unless a fixture overrides it.

methodrequestAnimationFrame(callback: PlatformFrameRequestCallback): number

Schedules a callback for the next host animation frame.

methodsetInterval(callback: (): void, _ms: number): number

Updates the interval.

methodsetTimeout(callback: (): void, _ms: number): number

Updates the timeout.

methodwarn(_message: string, ..._details: unknown[]): void

Records or emits a platform warning.

Inherited members 2

Inherited from Platform.

interfaceRenderCall

Test support contract for RenderCall.

propertyargs: unknown[]
propertyname: string