33 lines
1.6 KiB
JavaScript
33 lines
1.6 KiB
JavaScript
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)
|
|
})
|