1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 10:29:48 +02:00

fix tests missing selection, unskip some tests

This commit is contained in:
Ian Storm Taylor
2019-12-13 12:53:58 -05:00
parent d8b915a406
commit bb6a4d9ce8
15 changed files with 23 additions and 25 deletions

View File

@@ -10,6 +10,7 @@ describe('slate-history', () => {
run(editor) run(editor)
editor.exec({ type: 'undo' }) editor.exec({ type: 'undo' })
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection)
}) })
}) })

View File

@@ -4,7 +4,7 @@ import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.delete() Editor.delete(editor)
} }
export const input = ( export const input = (
@@ -18,5 +18,3 @@ export const input = (
) )
export const output = input export const output = input
export const skip = true

View File

@@ -4,7 +4,7 @@ import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.delete() Editor.delete(editor)
} }
export const input = ( export const input = (
@@ -21,5 +21,3 @@ export const input = (
) )
export const output = input export const output = input
export const skip = true

View File

@@ -4,7 +4,7 @@ import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.delete() Editor.delete(editor)
} }
export const input = ( export const input = (
@@ -29,5 +29,3 @@ export const input = (
) )
export const output = input export const output = input
export const skip = true

View File

@@ -38,5 +38,3 @@ export const input = (
) )
export const output = input export const output = input
export const skip = true

View File

@@ -1,12 +1,13 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.exec({ type: 'insert_text', text: 't' }) editor.exec({ type: 'insert_text', text: 't' })
// editor.move({ reverse: true }) Editor.move(editor, { reverse: true })
editor.exec({ type: 'insert_text', text: 'w' }) editor.exec({ type: 'insert_text', text: 'w' })
// editor.move({ reverse: true }) Editor.move(editor, { reverse: true })
editor.exec({ type: 'insert_text', text: 'o' }) editor.exec({ type: 'insert_text', text: 'o' })
} }

View File

@@ -313,6 +313,8 @@ export const GeneralTransforms = {
editor.selection = isDraft(selection) editor.selection = isDraft(selection)
? (finishDraft(selection) as Range) ? (finishDraft(selection) as Range)
: selection : selection
} else {
editor.selection = null
} }
}, },
} }

View File

@@ -28,7 +28,6 @@ export const NodeTransforms = {
} = {} } = {}
) { ) {
Editor.withoutNormalizing(editor, () => { Editor.withoutNormalizing(editor, () => {
const { selection } = editor
const { hanging = false, voids = false } = options const { hanging = false, voids = false } = options
let { at, match, select } = options let { at, match, select } = options

View File

@@ -21,6 +21,7 @@ describe('slate', () => {
}) })
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection)
}) })
fixtures(__dirname, 'normalization', ({ module }) => { fixtures(__dirname, 'normalization', ({ module }) => {
@@ -28,6 +29,7 @@ describe('slate', () => {
const editor = withTest(input) const editor = withTest(input)
Editor.normalize(editor, { force: true }) Editor.normalize(editor, { force: true })
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection)
}) })
fixtures(__dirname, 'queries', ({ module }) => { fixtures(__dirname, 'queries', ({ module }) => {
@@ -42,6 +44,7 @@ describe('slate', () => {
const editor = withTest(input) const editor = withTest(input)
run(editor) run(editor)
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection)
}) })
}) })

View File

@@ -41,5 +41,3 @@ export const output = (
</block> </block>
</editor> </editor>
) )
export const skip = true

View File

@@ -22,8 +22,9 @@ export const run = editor => {
export const output = ( export const output = (
<editor> <editor>
<block void> <block void>
onetwo one
<cursor /> <cursor />
two
</block> </block>
</editor> </editor>
) )

View File

@@ -28,8 +28,9 @@ export const output = (
<block> <block>
one one
<inline void> <inline void>
twofour two
<cursor /> <cursor />
four
</inline> </inline>
three three
</block> </block>

View File

@@ -20,7 +20,6 @@ export const input = (
</editor> </editor>
) )
// TODO: the hanging selection here isn't right
export const output = ( export const output = (
<editor> <editor>
<block> <block>

View File

@@ -24,8 +24,9 @@ export const output = (
<block> <block>
one one
<inline>two</inline> <inline>two</inline>
fourthree four
<cursor /> <cursor />
three
</block> </block>
</editor> </editor>
) )

View File

@@ -21,15 +21,15 @@ export const input = (
</editor> </editor>
) )
// TODO: the selection is wrong here
export const output = ( export const output = (
<editor> <editor>
<block>one</block> <block>one</block>
<block> <block>
<cursor /> <text />
</block>
<block>
<cursor />
three
</block> </block>
<block>three</block>
</editor> </editor>
) )
export const skip = true