1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-20 06:01:24 +02:00

Add unit test for testing insertTextByKey with marks

This commit is contained in:
Samy Pessé
2016-10-26 12:56:08 +02:00
parent 7c046a7b98
commit 9ae17d2091
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import assert from 'assert'
export default function (state) {
const { document, selection } = state
const texts = document.getTexts()
const firstText = texts.first()
const secondText = texts.get(1)
const nextSelection = selection.merge({
anchorKey: firstText.key,
focusKey: firstText.key,
anchorOffset: 2,
focusOffset: 2
})
const next = state
.transform()
.moveTo(nextSelection)
.insertTextByKey(secondText.key, 2, 'XX', [ { type: 'bold' } ])
.apply()
assert.deepEqual(
next.selection.toJS(),
nextSelection.toJS()
)
return next
}

View File

@@ -0,0 +1,12 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
text: outside
- kind: block
type: paragraph
nodes:
- kind: text
text: hello

View File

@@ -0,0 +1,17 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
text: outside
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: he
- text: XX
marks:
- type: bold
- text: llo