openpencil/tests/engine/pen/file.test.ts
Danila Poyarkov c3f5189f8f style: tighten import grouping
- Configure oxfmt custom import groups for workspace, app, package, and test aliases
- Keep type imports grouped with their matching source category instead of one global tail group
- Expand the format script to cover formatter config, Vite files, and scripts
2026-05-06 02:22:08 +03:00

39 lines
1.4 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import { parsePenFile } from '@open-pencil/core'
import { repoPath } from '#tests/helpers/paths'
const FIXTURE_DIR = repoPath('tests/fixtures')
async function loadFixture(name: string): Promise<string> {
return Bun.file(`${FIXTURE_DIR}/${name}`).text()
}
describe('parsePenFile', () => {
test('imports variables and theme modes', async () => {
const graph = parsePenFile(await loadFixture('pencil_simple.pen'))
const collections = [...graph.variableCollections.values()]
expect(collections.length).toBe(1)
expect(collections[0].modes.map((mode) => mode.name)).toEqual(['Light', 'Dark'])
expect(graph.variables.size).toBeGreaterThan(0)
})
test('maps reusable frames to components', async () => {
const graph = parsePenFile(await loadFixture('pencil_button.pen'))
const components = [...graph.getAllNodes()].filter((node) => node.type === 'COMPONENT')
expect(components.length).toBeGreaterThan(0)
expect(components[0]?.name).toContain('Button')
})
test('maps path geometry to vector nodes', async () => {
const graph = parsePenFile(await loadFixture('pencil_button.pen'))
const vectors = [...graph.getAllNodes()].filter((node) => node.type === 'VECTOR')
expect(vectors.length).toBeGreaterThan(0)
expect(vectors.some((node) => (node.vectorNetwork?.vertices.length ?? 0) > 0)).toBe(true)
})
})