mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +02:00
Test undo for insertNode, moveNode, removeNode
This commit is contained in:
@@ -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
|
||||||
|
}
|
@@ -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
|
@@ -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
|
18
test/transforms/fixtures/on-history/undo/move-node/index.js
Normal file
18
test/transforms/fixtures/on-history/undo/move-node/index.js
Normal 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
|
||||||
|
}
|
@@ -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
|
@@ -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
|
@@ -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
|
||||||
|
}
|
@@ -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
|
@@ -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
|
Reference in New Issue
Block a user