openpencil/tests/engine/figma/api/grouping.test.ts
Danila Poyarkov 9ebc61d78f test(figma): split API coverage
- Move FigmaAPI tests into focused files by feature area
- Share API construction from figma/api/helpers.ts
- Remove FigmaAPI coverage from max-lines exceptions
2026-05-06 13:37:15 +03:00

28 lines
847 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { expectDefined } from '#tests/helpers/assert'
import { createAPI } from './helpers'
describe('grouping', () => {
test('group creates GROUP with children', () => {
const api = createAPI()
const a = api.createRectangle()
const b = api.createEllipse()
const group = api.group([a, b], api.currentPage)
expect(group.type).toBe('GROUP')
expect(group.children.length).toBe(2)
})
test('ungroup dissolves group', () => {
const api = createAPI()
const a = api.createRectangle()
const b = api.createEllipse()
const group = api.group([a, b], api.currentPage)
const groupId = group.id
api.ungroup(group)
expect(api.getNodeById(groupId)).toBeNull()
expect(expectDefined(a.parent, 'ungrouped parent').id).toBe(api.currentPage.id)
})
})