1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

Add tests for collapseToStart/End when selected node is void (#1038)

This commit is contained in:
Per-Kristian Nordnes
2017-09-05 18:21:26 +02:00
committed by Ian Storm Taylor
parent 044ffbf62c
commit e79ec24f39
4 changed files with 68 additions and 0 deletions

View File

@@ -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,
})
}

View File

@@ -0,0 +1,5 @@
nodes:
- kind: block
type: image
isVoid: true

View File

@@ -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,
})
}

View File

@@ -0,0 +1,5 @@
nodes:
- kind: block
type: image
isVoid: true