← All packages

API reference

@searsuite/sear-assembly-test

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

11 exportsderived from source

classRecordingRenderContextsource ↗
class RecordingRenderContext extends RenderContext

RenderContext implementation that records drawing calls without Canvas pixels.

constructorconstructor
RecordingRenderContext(): RecordingRenderContext
propertycalls
readonly calls: RenderCall[]

Recorded render calls captured by RecordingRenderContext.

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

Adds the click event listener.

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

Adds the event listener.

type: string
callBack: (event: EventWithOffset): void
methodaddMouseDownEventListener
addMouseDownEventListener(callBack: (event: EventWithOffset): void): void

Adds the mouse down event listener.

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

Adds the mouse move event listener.

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

Adds the mouse up event listener.

callBack: (event: EventWithOffset): void
methodaddResizeListener
addResizeListener(_callBack: (): void): void

Adds the resize listener.

_callBack: (): void
methodbeginPath
beginPath(): void

Begins a recorded vector path.

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

Records a rectangular clear operation.

x: number
y: number
width: number
height: number
methodclip
clip(): void

Clips subsequent recorded operations to the current path.

methodcloneNode
cloneNode(): RenderContext

Creates an independent copy of a recorded render node.

methodclosePath
closePath(): void

Closes the current recorded vector path.

methodcreateHitNode
createHitNode(): 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.

image: unknown
x: number
y: number
width: number
height: number
sx: number
sy: number
sWidth: number
sHeight: number
methodfill
fill(): void

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

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

Records text painting at the supplied position.

text: string
x: number
y: number
maxWidth: number
methodgetAttribute
getAttribute(name: string): string

Returns the attribute.

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

Returns the image data.

_x: number
_y: number
_width: number
_height: number
methodgetLineWidth
getLineWidth(): number

Returns the line width.

methodgetMaxLineWidth
getMaxLineWidth(): number

Returns the max line width.

methodgetRasterScale
getRasterScale(): number

Returns the raster scale.

methodgetRenderTarget
getRenderTarget(): object

Returns the render target.

methodgetRoot
getRoot(): EventTarget

Returns the root.

methodgetViewScale
getViewScale(): number

Returns the view scale.

methodinitialize
initialize(_scale?: number): void

Initializes the recording context for a render target.

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

Adds a line segment to the current recorded path.

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

Measures text with the recording context's configured metrics.

text: string
methodmoveTo
moveTo(x: number, y: number): void

Moves the current recorded path without drawing a segment.

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

Records raw pixel data at the supplied position.

imageData: RenderImageData
x: number
y: number
methodrect
rect(x: number, y: number, width: number, height: number): void

Adds a rectangle to the current recorded path.

x: number
y: number
width: number
height: number
methodremoveClickEventListener
removeClickEventListener(callBack: (event: EventWithOffset): void): void

Removes the click event listener.

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

Removes the mouse down event listener.

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

Removes the mouse move event listener.

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

Removes the mouse up event listener.

callBack: (event: EventWithOffset): void
methodremoveResizeListener
removeResizeListener(): void

Removes the resize listener.

methodresetTransform
resetTransform(): void

Restores the recorded transform to the identity matrix.

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

Resizes the render target and invalidates dependent frame state.

width: number
height: number
scale: number
methodrestore
restore(): void

Restores the most recently saved render state.

methodsave
save(): void

Pushes the current render state onto the recording stack.

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

Updates the attribute.

name: string
value: string
methodsetFillStyle
setFillStyle(fillStyle: RenderPaint): void

Updates the fill style.

fillStyle: RenderPaint
methodsetFont
setFont(font: string): void

Updates the font.

font: string
methodsetLineDash
setLineDash(segments: number[]): void

Updates the line dash.

segments: number[]
methodsetLineWidth
setLineWidth(width: number): void

Updates the line width.

width: number
methodsetStrokeStyle
setStrokeStyle(strokeStyle: RenderPaint): void

Updates the stroke style.

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

Updates the transform.

a: number
b: number
c: number
d: number
e: number
f: number
methodsetViewScale
setViewScale(scale: number): void

Updates the view scale.

scale: number
methodstroke
stroke(): void

Strokes the current recorded path.

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

Records a stroked rectangle operation.

x: number
y: number
width: number
height: number
methodtranslate
translate(x: number, y: number): void

Offsets subsequent recorded operations by the supplied vector.

x: number
y: number
Inherited members 11

Inherited from RenderContext.

classTestPlatformsource ↗
class TestPlatform extends Platform

Deterministic Platform implementation for harnesses and integration tests.

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

Registers a host event listener and returns an idempotent disposer.

_target: unknown
_type: string
_listener: (event: unknown): void
methodcancelAnimationFrame
cancelAnimationFrame(handle: number): void

Cancels a previously scheduled host animation frame.

handle: number
methodclearInterval
clearInterval(handle: number): void

Cancels a repeating host timer.

handle: number
methodclearTimeout
clearTimeout(handle: number): void

Cancels a one-shot host timer.

handle: number
methodcreateId
createId(prefix?: string): string

Creates a deterministic test identifier.

prefix: string
methodcurrentDateTime
currentDateTime(): number

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

methoddestroy
destroy(): void

Releases resources owned by TestPlatform.

methodflush
flush(): void

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

methodnow
now(): number

Returns the current test platform time.

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

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

_target: unknown
_callback: (size: { height: number; width: number }): void
methodqueueMicrotask
queueMicrotask(callback: (): void): void

Queues a microtask in the test platform.

callback: (): void
methodreadViewOffset
readViewOffset(_target: unknown): PlatformViewOffset

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

_target: unknown
methodrequestAnimationFrame
requestAnimationFrame(callback: PlatformFrameRequestCallback): number

Schedules a callback for the next host animation frame.

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

Updates the interval.

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

Updates the timeout.

callback: (): void
_ms: number
methodwarn
warn(_message: string, ..._details: unknown[]): void

Records or emits a platform warning.

_message: string
_details: unknown[]
Inherited members 2

Inherited from Platform.

interfaceCreateTestSheetOptionssource ↗
interface CreateTestSheetOptions

Test support contract for CreateTestSheetOptions.

propertyevents
events?: string[]
propertyplugins
plugins?: TestPluginRegistration[]
propertyproviders
providers?: TestProviderOverride[]
propertysheet
sheet?: TestSheetDataOptions
propertyviewport
viewport?: { height: number; width: number }
interfaceRenderCallsource ↗
interface RenderCall

Test support contract for RenderCall.

propertyargs
args: unknown[]
propertyname
name: string
interfaceTestPluginRegistrationsource ↗
interface TestPluginRegistration

Test support contract for TestPluginRegistration.

propertyimplementation
implementation: (...args: never[]): Plugin<SearCoreSheet, CellProperties, unknown>
propertytoken
token: symbol
interfaceTestProviderOverridesource ↗
interface TestProviderOverride

Test support contract for TestProviderOverride.

methodregister
register(container: Container): void
container: Container
interfaceTestSheetCellsource ↗
interface TestSheetCell

Test support contract for TestSheetCell.

propertycol
col: number
propertyrow
row: number
propertyvalue
value: CellMatrixElement
interfaceTestSheetDataOptionssource ↗
interface TestSheetDataOptions

Test support contract for TestSheetDataOptions.

propertycells
cells?: TestSheetCell[]
propertycolCount
colCount?: number
propertycolWidth
colWidth?: number
propertyrowCount
rowCount?: number
propertyrowHeight
rowHeight?: number
interfaceTestSheetHarnesssource ↗
interface TestSheetHarness

Test support contract for TestSheetHarness.

propertycommands
readonly commands: SheetCommandBus
propertycontainer
readonly container: Container
propertycore
readonly core: SearCoreSheet
propertyhitRenderContext
readonly hitRenderContext: RecordingRenderContext
propertyoffScreenRenderContext
readonly offScreenRenderContext: RecordingRenderContext
propertyrenderContext
readonly renderContext: RecordingRenderContext
propertystage
readonly stage: SceneGraph<CellProperties>
methoddestroy
destroy(): void
methodexecuteTransaction
executeTransaction(transaction: Transaction): void
transaction: Transaction
methodflush
flush(): void
functioncreateTestSheetsource ↗
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.

options: CreateTestSheetOptions
functionreplacesource ↗
replace<T>(token: symbol, instance: T): TestProviderOverride

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

token: symbol
instance: T