2026-05-06 10:36:48 +00:00
|
|
|
import { describe, expect, test } from 'bun:test'
|
|
|
|
|
|
2026-05-06 11:27:21 +00:00
|
|
|
import { createAPI } from '../helpers'
|
2026-05-06 10:36:48 +00:00
|
|
|
|
|
|
|
|
describe('absolute position', () => {
|
|
|
|
|
test('absoluteBoundingBox accounts for nesting', () => {
|
|
|
|
|
const api = createAPI()
|
|
|
|
|
const parent = api.createFrame()
|
|
|
|
|
parent.x = 100
|
|
|
|
|
parent.y = 200
|
|
|
|
|
const child = api.createRectangle()
|
|
|
|
|
parent.appendChild(child)
|
|
|
|
|
child.x = 10
|
|
|
|
|
child.y = 20
|
|
|
|
|
child.resize(50, 30)
|
|
|
|
|
const bounds = child.absoluteBoundingBox
|
|
|
|
|
expect(bounds.x).toBe(110)
|
|
|
|
|
expect(bounds.y).toBe(220)
|
|
|
|
|
expect(bounds.width).toBe(50)
|
|
|
|
|
expect(bounds.height).toBe(30)
|
|
|
|
|
})
|
|
|
|
|
})
|