에디터 슬래시 상태와 단축키 판별 분리

This commit is contained in:
2026-07-27 12:09:47 +09:00
parent 358199e595
commit bf48af7bd3
10 changed files with 361 additions and 69 deletions

View 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)
})