1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 18:09:49 +02:00

Test undo setSelection

This commit is contained in:
Soreine
2016-11-09 15:10:50 +01:00
parent c8b61bafee
commit 9cc1140009
3 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import assert from 'assert'
export default function (state) {
const { selection, document } = state
const dest = document.getDescendant('key2')
let next = state
.transform()
// Make a dummy change to the doc, so that the selection operation can be undone
.setNodeByKey(document.nodes.first().key, { data: { any: 'thing' } })
.setSelectionOperation(selection.moveToRangeOf(dest))
.apply()
.transform()
.undo()
.apply()
assert.deepEqual(next.selection.toJS(), selection.toJS())
return next
}

View File

@@ -0,0 +1,14 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
key: 'key1'
text: The
- kind: block
type: paragraph
nodes:
- kind: text
key: 'key2'
text: text

View File

@@ -0,0 +1,14 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
key: 'key1'
text: The
- kind: block
type: paragraph
nodes:
- kind: text
key: 'key2'
text: text