openpencil/tests/helpers/tools.ts
Danila Poyarkov 39675b2969 chore(tests): remove easy non-null assertions
- 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
2026-05-06 02:59:56 +03:00

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}`
)
}