- Replace browser store non-null assertions with explicit initialization guards - Use expectDefined for optional test resources and tool results - Clean low-count non-null assertions in font, icon, snap, OKHCL, and visual tests
29 lines
631 B
TypeScript
29 lines
631 B
TypeScript
import { ALL_TOOLS, FigmaAPI, SceneGraph } from '@open-pencil/core'
|
|
|
|
export { ALL_TOOLS }
|
|
|
|
import { expectDefined } from './assert'
|
|
|
|
export interface ToolResult {
|
|
id?: string
|
|
name?: string
|
|
type?: string
|
|
error?: string
|
|
count?: number
|
|
nodes?: Array<{ id?: string; name: string; type: string }>
|
|
[key: string]: unknown
|
|
}
|
|
|
|
export function setupToolTest() {
|
|
const graph = new SceneGraph()
|
|
const figma = new FigmaAPI(graph)
|
|
return { graph, figma }
|
|
}
|
|
|
|
export function getTool(name: string): (typeof ALL_TOOLS)[number] {
|
|
return expectDefined(
|
|
ALL_TOOLS.find((tool) => tool.name === name),
|
|
`tool ${name}`
|
|
)
|
|
}
|