diff --git a/test/transforms/fixtures/on-history/undo/set-selection/index.js b/test/transforms/fixtures/on-history/undo/set-selection/index.js new file mode 100644 index 000000000..b319d4273 --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-selection/index.js @@ -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 +} diff --git a/test/transforms/fixtures/on-history/undo/set-selection/input.yaml b/test/transforms/fixtures/on-history/undo/set-selection/input.yaml new file mode 100644 index 000000000..bad8a9f8d --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-selection/input.yaml @@ -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 diff --git a/test/transforms/fixtures/on-history/undo/set-selection/output.yaml b/test/transforms/fixtures/on-history/undo/set-selection/output.yaml new file mode 100644 index 000000000..bad8a9f8d --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-selection/output.yaml @@ -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