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

Test undo for insertNode, moveNode, removeNode

This commit is contained in:
Soreine
2016-11-09 14:54:23 +01:00
parent 78a9eb24f0
commit c8b61bafee
9 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import assert from 'assert'
import { Block } from '../../../../../..'
export default function (state) {
const { selection } = state
let next = state
.transform()
.insertNodeByKey('key1', 0, Block.create({ type: 'default' }))
.apply()
.transform()
.undo()
.apply()
assert.deepEqual(next.selection.toJS(), selection.toJS())
return next
}

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
import assert from 'assert'
export default function (state) {
const { selection } = state
let next = state
.transform()
.moveNodeByKey('key2', 'key1', 0)
.apply()
.transform()
.undo()
.apply()
assert.deepEqual(next.selection.toJS(), selection.toJS())
return next
}

View File

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

View File

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

View File

@@ -0,0 +1,17 @@
import assert from 'assert'
export default function (state) {
const { selection } = state
let next = state
.transform()
.removeNodeByKey('key1')
.apply()
.transform()
.undo()
.apply()
return next
}

View File

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

View File

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