1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-27 09:04:31 +02:00

Ensure round-trip tests don't mutate output before checking against it => reveals 4 tests are broken (#4188)

* Ensure round-trip tests don't mutate output before checking against it.  Need deep copy instead of shallow.

* Skip the 4 tests that are broken - they should perhaps be fixed in a separate PR
This commit is contained in:
Bjørn Stabell
2021-05-07 06:52:55 -07:00
committed by GitHub
parent 1808d0ed9e
commit b4eeccb017
13 changed files with 30 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
@@ -14,4 +15,5 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const skip = true // TODO: see https://github.com/ianstormtaylor/slate/pull/4188
export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
@@ -17,4 +18,5 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const skip = true // TODO: see https://github.com/ianstormtaylor/slate/pull/4188
export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
@@ -25,4 +26,5 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const skip = true // TODO: see https://github.com/ianstormtaylor/slate/pull/4188
export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
editor.insertBreak() editor.insertBreak()
@@ -16,4 +17,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)

View File

@@ -1,5 +1,6 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
const fragment = ( const fragment = (
<block type="d"> <block type="d">
@@ -33,5 +34,5 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)
export const skip = true export const skip = true

View File

@@ -1,5 +1,6 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
editor.insertText('text') editor.insertText('text')
@@ -12,4 +13,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)

View File

@@ -1,5 +1,6 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
editor.insertText('t') editor.insertText('t')
@@ -14,4 +15,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Node } from 'slate' import { Node } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
import { cloneDeep } from 'lodash'
export const input = ( export const input = (
<editor> <editor>
@@ -12,4 +13,4 @@ export const input = (
export const test = value => { export const test = value => {
return Node.ancestor(value, [0]) return Node.ancestor(value, [0])
} }
export const output = input.children[0] export const output = cloneDeep(input.children[0])

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Node } from 'slate' import { Node } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
import { cloneDeep } from 'lodash'
export const input = ( export const input = (
<editor> <editor>
@@ -12,4 +13,4 @@ export const input = (
export const test = value => { export const test = value => {
return Node.child(value, 0) return Node.child(value, 0)
} }
export const output = input.children[0] export const output = cloneDeep(input.children[0])

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Node } from 'slate' import { Node } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
import { cloneDeep } from 'lodash'
export const input = ( export const input = (
<editor> <editor>
@@ -12,4 +13,4 @@ export const input = (
export const test = value => { export const test = value => {
return Node.descendant(value, [0]) return Node.descendant(value, [0])
} }
export const output = input.children[0] export const output = cloneDeep(input.children[0])

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Node } from 'slate' import { Node } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
import { cloneDeep } from 'lodash'
export const input = ( export const input = (
<editor> <editor>
@@ -12,4 +13,5 @@ export const input = (
export const test = value => { export const test = value => {
return Node.get(value, []) return Node.get(value, [])
} }
export const output = input export const skip = true // TODO: see https://github.com/ianstormtaylor/slate/pull/4188
export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
Transforms.delete(editor, { unit: 'line' }) Transforms.delete(editor, { unit: 'line' })
@@ -13,4 +14,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)

View File

@@ -1,6 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
import { cloneDeep } from 'lodash'
export const run = editor => { export const run = editor => {
Transforms.delete(editor, { unit: 'line', reverse: true }) Transforms.delete(editor, { unit: 'line', reverse: true })
@@ -13,4 +14,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = cloneDeep(input)