WYSIWYG: Moveable 가이드라인 고도화(중심/가장자리 스냅, 8px 임계) TDD/구현 및 테스트
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import React from 'react'
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render } from '@testing-library/react'
|
||||
import { Canvas } from '@/components/wysiwyg/Canvas'
|
||||
import type { Frame } from '@/lib/wysiwyg/schema'
|
||||
|
||||
const capture = vi.fn()
|
||||
|
||||
vi.mock('react-moveable', () => {
|
||||
const Mock = (props: Record<string, unknown>) => {
|
||||
capture(props)
|
||||
return <div data-testid="moveable" />
|
||||
}
|
||||
return { default: Mock }
|
||||
})
|
||||
|
||||
const frame: Frame = {
|
||||
id: 'f-target',
|
||||
width: 300,
|
||||
height: 200,
|
||||
background: '#fff',
|
||||
layers: [
|
||||
{ id: 'l1', name: 'L1', visible: true, locked: false, objects: [
|
||||
{ id: 'o1', type: 'text', x: 8, y: 8, width: 80, height: 30, rotate: 0, zIndex: 0, props: { text: 'A', fontSize: 16, color: '#000' } },
|
||||
{ id: 'o2', type: 'text', x: 96, y: 8, width: 80, height: 30, rotate: 0, zIndex: 1, props: { text: 'B', fontSize: 16, color: '#000' } },
|
||||
]}
|
||||
]
|
||||
}
|
||||
|
||||
describe('Canvas + Moveable target binding', () => {
|
||||
beforeEach(() => {
|
||||
capture.mockReset()
|
||||
})
|
||||
|
||||
it('passes the selected object selector as Moveable target', () => {
|
||||
const { getByTestId } = render(<Canvas frame={frame} />)
|
||||
|
||||
// 기본 선택은 첫 객체(o1)라고 가정
|
||||
const el = getByTestId('obj-o1')
|
||||
const last = capture.mock.calls.at(-1)?.[0] as { target?: string }
|
||||
expect(last).toBeTruthy()
|
||||
expect(last?.target).toBe('[data-testid="obj-o1"]')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user