WYSIWYG: 키보드 nudge(Shift 1px 비스냅, Alt 16px 스냅) TDD/구현 및 테스트
This commit is contained in:
@@ -41,4 +41,31 @@ describe('WYSIWYG Canvas keyboard nudge with 8px snap', () => {
|
||||
const obj = getByTestId('obj-o1')
|
||||
expect(obj).toHaveStyle({ top: '96px' }) // 100 - 1 => 99 -> snap8 => 96
|
||||
})
|
||||
|
||||
it('Shift+ArrowRight nudges by 1px without grid snap', () => {
|
||||
const frame = makeFrame()
|
||||
const { getByTestId } = render(<Canvas frame={frame} />)
|
||||
const canvas = getByTestId('wysiwyg-canvas')
|
||||
fireEvent.keyDown(canvas, { key: 'ArrowRight', shiftKey: true })
|
||||
const obj = getByTestId('obj-o1')
|
||||
expect(obj).toHaveStyle({ left: '102px' }) // 101 + 1 => 102 (no snap)
|
||||
})
|
||||
|
||||
it('Shift+ArrowUp nudges by 1px without grid snap', () => {
|
||||
const frame = makeFrame()
|
||||
const { getByTestId } = render(<Canvas frame={frame} />)
|
||||
const canvas = getByTestId('wysiwyg-canvas')
|
||||
fireEvent.keyDown(canvas, { key: 'ArrowUp', shiftKey: true })
|
||||
const obj = getByTestId('obj-o1')
|
||||
expect(obj).toHaveStyle({ top: '99px' }) // 100 - 1 => 99 (no snap)
|
||||
})
|
||||
|
||||
it('Alt+ArrowRight nudges by 16px and snaps to grid', () => {
|
||||
const frame = makeFrame()
|
||||
const { getByTestId } = render(<Canvas frame={frame} />)
|
||||
const canvas = getByTestId('wysiwyg-canvas')
|
||||
fireEvent.keyDown(canvas, { key: 'ArrowRight', altKey: true })
|
||||
const obj = getByTestId('obj-o1')
|
||||
expect(obj).toHaveStyle({ left: '120px' }) // 101 + 16 = 117 -> snap8 => 120
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user