슬래시 하이라이트 인덱스 보정 분리

This commit is contained in:
2026-07-27 11:49:05 +09:00
parent a39944b139
commit 5803e1927c
7 changed files with 38 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import {
addSlashSuppressedLine,
clampSlashHighlightedIndex,
getMediaPickerKindFromSlashAction,
getSlashCommandFocusTarget,
getSlashCommandTextareaSelection,
@@ -67,6 +68,14 @@ test('슬래시 제외 줄 Set은 유효하지 않은 줄 번호를 무시한다
assert.deepEqual([...removeSlashSuppressedLine(new Set([1]), Number.NaN)], [1])
})
test('슬래시 메뉴 하이라이트 인덱스는 명령 목록 범위 안으로 보정한다', () => {
assert.equal(clampSlashHighlightedIndex(3, 5), 3)
assert.equal(clampSlashHighlightedIndex(7, 5), 4)
assert.equal(clampSlashHighlightedIndex(-2, 5), 0)
assert.equal(clampSlashHighlightedIndex(2, 0), 0)
assert.equal(clampSlashHighlightedIndex(Number.NaN, Number.NaN), 0)
})
test('슬래시 명령 줄에 미디어를 삽입할 때 원문 줄을 교체한다', () => {
const markdown = [
'첫 줄',