에디터 슬래시 상태와 단축키 판별 분리
This commit is contained in:
32
tests/markdown-editor-keyboard.test.js
Normal file
32
tests/markdown-editor-keyboard.test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import {
|
||||
getEditorHistoryKeyboardAction,
|
||||
hasEditorCommandModifier,
|
||||
isEditorModeToggleShortcut,
|
||||
isMediaPickerCloseShortcut
|
||||
} from '../lib/markdown-editor-keyboard.js'
|
||||
|
||||
test('에디터 Cmd/Ctrl 조합 여부를 판별한다', () => {
|
||||
assert.equal(hasEditorCommandModifier({ metaKey: true }), true)
|
||||
assert.equal(hasEditorCommandModifier({ ctrlKey: true }), true)
|
||||
assert.equal(hasEditorCommandModifier({ metaKey: false, ctrlKey: false }), false)
|
||||
assert.equal(hasEditorCommandModifier(null), false)
|
||||
})
|
||||
|
||||
test('에디터 히스토리 단축키는 undo와 redo를 구분한다', () => {
|
||||
assert.equal(getEditorHistoryKeyboardAction({ metaKey: true, key: 'z' }), 'undo')
|
||||
assert.equal(getEditorHistoryKeyboardAction({ ctrlKey: true, key: 'Z' }), 'undo')
|
||||
assert.equal(getEditorHistoryKeyboardAction({ metaKey: true, shiftKey: true, key: 'z' }), 'redo')
|
||||
assert.equal(getEditorHistoryKeyboardAction({ ctrlKey: true, key: 'y' }), 'redo')
|
||||
assert.equal(getEditorHistoryKeyboardAction({ metaKey: true, altKey: true, key: 'z' }), '')
|
||||
assert.equal(getEditorHistoryKeyboardAction({ key: 'z' }), '')
|
||||
})
|
||||
|
||||
test('에디터 모드 전환과 미디어 선택 닫기 단축키를 판별한다', () => {
|
||||
assert.equal(isEditorModeToggleShortcut({ metaKey: true, key: 'e' }), true)
|
||||
assert.equal(isEditorModeToggleShortcut({ ctrlKey: true, key: 'E' }), true)
|
||||
assert.equal(isEditorModeToggleShortcut({ key: 'e' }), false)
|
||||
assert.equal(isMediaPickerCloseShortcut({ key: 'Escape' }), true)
|
||||
assert.equal(isMediaPickerCloseShortcut({ key: 'Enter' }), false)
|
||||
})
|
||||
68
tests/useAdminMarkdownSlashMenu.test.js
Normal file
68
tests/useAdminMarkdownSlashMenu.test.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { useAdminMarkdownSlashMenu } from '../composables/useAdminMarkdownSlashMenu.js'
|
||||
|
||||
test('관리자 Markdown 슬래시 메뉴 상태는 열기와 초기화를 관리한다', () => {
|
||||
const slashMenu = useAdminMarkdownSlashMenu()
|
||||
|
||||
slashMenu.openLiveSlashMenu(2, 'image')
|
||||
|
||||
assert.equal(slashMenu.liveSlashVisible.value, true)
|
||||
assert.equal(slashMenu.liveSlashSourceLine.value, 2)
|
||||
assert.equal(slashMenu.liveSlashQuery.value, 'image')
|
||||
assert.equal(slashMenu.visibleLiveSlashCommands.value[0]?.id, 'image')
|
||||
|
||||
slashMenu.clearLiveSlashState()
|
||||
|
||||
assert.equal(slashMenu.liveSlashVisible.value, false)
|
||||
assert.equal(slashMenu.liveSlashSourceLine.value, null)
|
||||
assert.equal(slashMenu.liveSlashQuery.value, '')
|
||||
assert.equal(slashMenu.liveSlashHighlightedIndex.value, 0)
|
||||
})
|
||||
|
||||
test('관리자 Markdown 슬래시 메뉴 억제 줄은 추가와 해제를 분리한다', () => {
|
||||
const slashMenu = useAdminMarkdownSlashMenu()
|
||||
|
||||
slashMenu.suppressLiveSlashLine(3)
|
||||
slashMenu.suppressLiveSlashLine(Number.NaN)
|
||||
|
||||
assert.equal(slashMenu.isLiveSlashLineSuppressed(3), true)
|
||||
assert.deepEqual(slashMenu.liveSlashSuppressedLineList.value, [3])
|
||||
|
||||
slashMenu.releaseLiveSlashLine(3)
|
||||
|
||||
assert.equal(slashMenu.isLiveSlashLineSuppressed(3), false)
|
||||
assert.deepEqual(slashMenu.liveSlashSuppressedLineList.value, [])
|
||||
})
|
||||
|
||||
test('관리자 Markdown 슬래시 메뉴 하이라이트는 검색어와 명령 개수에 맞춰 보정한다', () => {
|
||||
const slashMenu = useAdminMarkdownSlashMenu()
|
||||
|
||||
slashMenu.liveSlashHighlightedIndex.value = 9
|
||||
slashMenu.clampLiveSlashHighlightedIndex(3)
|
||||
|
||||
assert.equal(slashMenu.liveSlashHighlightedIndex.value, 2)
|
||||
|
||||
slashMenu.resetLiveSlashHighlightedIndex()
|
||||
|
||||
assert.equal(slashMenu.liveSlashHighlightedIndex.value, 0)
|
||||
})
|
||||
|
||||
test('관리자 Markdown 슬래시 메뉴 키보드 탐색 상태는 타이머로 정리한다', async () => {
|
||||
const slashMenu = useAdminMarkdownSlashMenu()
|
||||
|
||||
slashMenu.startLiveSlashKeyboardNavigation(10)
|
||||
|
||||
assert.equal(slashMenu.liveSlashKeyboardNav.value, true)
|
||||
|
||||
await new Promise((resolve) => {
|
||||
globalThis.setTimeout(resolve, 20)
|
||||
})
|
||||
|
||||
assert.equal(slashMenu.liveSlashKeyboardNav.value, false)
|
||||
|
||||
slashMenu.startLiveSlashKeyboardNavigation(100)
|
||||
slashMenu.stopLiveSlashKeyboardNavigation()
|
||||
|
||||
assert.equal(slashMenu.liveSlashKeyboardNav.value, false)
|
||||
})
|
||||
Reference in New Issue
Block a user