mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: add ci and op convert insert test
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import toSync from './toSync'
|
||||
import hexGen from './hexGen'
|
||||
|
||||
export * from './testUtils'
|
||||
|
||||
const toJS = node => {
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(node))
|
||||
|
||||
24
packages/bridge/src/utils/testUtils.ts
Normal file
24
packages/bridge/src/utils/testUtils.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as Automerge from 'automerge'
|
||||
import { ValueJSON, TextJSON, NodeJSON } from 'slate'
|
||||
|
||||
export const createTextJSON = (text: string = ''): TextJSON => ({
|
||||
object: 'text',
|
||||
marks: [],
|
||||
text
|
||||
})
|
||||
|
||||
export const createParagraphJSON = (text: string = ''): NodeJSON => ({
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
nodes: [createTextJSON(text)]
|
||||
})
|
||||
|
||||
export const createValueJSON = (): ValueJSON => ({
|
||||
document: {
|
||||
nodes: [createParagraphJSON()]
|
||||
}
|
||||
})
|
||||
|
||||
export const createDoc = () => Automerge.from(createValueJSON())
|
||||
|
||||
export const cloneDoc = doc => Automerge.change(doc, '', d => d)
|
||||
Reference in New Issue
Block a user