openpencil/tests/engine/figma/api/vector/paths.test.ts
Danila Poyarkov 8c31d5ed87 feat(figma-api): expose vector paths and modes
- Return SVG path data for imported vector geometry

- Report explicit and inherited variable modes on node proxies
2026-07-22 15:07:20 +03:00

29 lines
842 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { encodePathCommandsBlob } from '@open-pencil/fig/node-change'
import { createAPI } from '../helpers'
describe('vector paths', () => {
test('exposes imported geometry as Figma SVG paths', () => {
const api = createAPI()
const vector = api.createVector()
api.graph.updateNode(vector.id, {
fillGeometry: [
{
windingRule: 'EVENODD',
commandsBlob: encodePathCommandsBlob([
{ type: 'M', x: 0, y: 0 },
{ type: 'L', x: 10, y: 10 },
{ type: 'Z' }
])
}
]
})
expect(vector.vectorPaths).toEqual([{ windingRule: 'EVENODD', data: 'M0 0L10 -10Z' }])
expect(Object.isFrozen(vector.vectorPaths)).toBe(true)
expect(Object.isFrozen(vector.vectorPaths[0])).toBe(true)
})
})