diff --git a/test/transforms/fixtures/on-selection/collapse-to-end/void/index.js b/test/transforms/fixtures/on-selection/collapse-to-end/void/index.js new file mode 100644 index 000000000..8d7595efe --- /dev/null +++ b/test/transforms/fixtures/on-selection/collapse-to-end/void/index.js @@ -0,0 +1,29 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.get(0) + + const next = state + .transform() + .select({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) + .collapseToEnd() + .apply() + + assert.deepEqual(next.selection.toJS(), { + anchorKey: first.key, + anchorOffset: 1, + focusKey: first.key, + focusOffset: 1, + isBackward: false, + isFocused: false, + marks: null, + }) +} diff --git a/test/transforms/fixtures/on-selection/collapse-to-end/void/input.yaml b/test/transforms/fixtures/on-selection/collapse-to-end/void/input.yaml new file mode 100644 index 000000000..8246cfbed --- /dev/null +++ b/test/transforms/fixtures/on-selection/collapse-to-end/void/input.yaml @@ -0,0 +1,5 @@ + +nodes: + - kind: block + type: image + isVoid: true diff --git a/test/transforms/fixtures/on-selection/collapse-to-start/void/index.js b/test/transforms/fixtures/on-selection/collapse-to-start/void/index.js new file mode 100644 index 000000000..76d0f1b4c --- /dev/null +++ b/test/transforms/fixtures/on-selection/collapse-to-start/void/index.js @@ -0,0 +1,29 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.get(0) + + const next = state + .transform() + .select({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) + .collapseToStart() + .apply() + + assert.deepEqual(next.selection.toJS(), { + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 0, + isBackward: false, + isFocused: false, + marks: null, + }) +} diff --git a/test/transforms/fixtures/on-selection/collapse-to-start/void/input.yaml b/test/transforms/fixtures/on-selection/collapse-to-start/void/input.yaml new file mode 100644 index 000000000..8246cfbed --- /dev/null +++ b/test/transforms/fixtures/on-selection/collapse-to-start/void/input.yaml @@ -0,0 +1,5 @@ + +nodes: + - kind: block + type: image + isVoid: true