mirror of
https://github.com/cudr/slate-collaborative.git
synced 2025-06-13 12:54:04 +00:00
fix: cleanup getTarget test case
This commit is contained in:
parent
e0b342585a
commit
e5ec4bf4c4
@ -7,6 +7,7 @@ import { createDoc, SyncDoc, toJS, toSlateOp } from '@hiveteams/collab-bridge'
|
|||||||
import AutomergeCollaboration from '@hiveteams/collab-backend/lib/AutomergeCollaboration'
|
import AutomergeCollaboration from '@hiveteams/collab-backend/lib/AutomergeCollaboration'
|
||||||
import withIOCollaboration from './withIOCollaboration'
|
import withIOCollaboration from './withIOCollaboration'
|
||||||
import { AutomergeOptions, SocketIOPluginOptions } from './interfaces'
|
import { AutomergeOptions, SocketIOPluginOptions } from './interfaces'
|
||||||
|
import { getTarget } from '@hiveteams/collab-bridge/src/path'
|
||||||
|
|
||||||
const connectionSlug = 'test'
|
const connectionSlug = 'test'
|
||||||
const docId = `/${connectionSlug}`
|
const docId = `/${connectionSlug}`
|
||||||
@ -213,23 +214,6 @@ describe('automerge editor client tests', () => {
|
|||||||
toSlateOp(operations, currentDoc)
|
toSlateOp(operations, currentDoc)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not throw index error', () => {
|
|
||||||
// Read from our test json file for the deep tree error
|
|
||||||
// This allows us to easily reproduce real production errors
|
|
||||||
// and create test cases that resolve those errors
|
|
||||||
const rawData = fs.readFileSync(
|
|
||||||
`${__dirname}/test-json/index-error.json`,
|
|
||||||
'utf-8'
|
|
||||||
)
|
|
||||||
const parsedData = JSON.parse(rawData)
|
|
||||||
const { current, operations } = parsedData
|
|
||||||
const currentDoc = Automerge.load<SyncDoc>(current)
|
|
||||||
|
|
||||||
// ensure no errors throw when removing a deep tree node
|
|
||||||
// that has already been removed
|
|
||||||
toSlateOp(operations, currentDoc)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should update children for a root level children operation', async () => {
|
it('should update children for a root level children operation', async () => {
|
||||||
const editor = await createCollabEditor()
|
const editor = await createCollabEditor()
|
||||||
|
|
||||||
@ -274,6 +258,13 @@ describe('automerge editor client tests', () => {
|
|||||||
expect(slateOps.length).toEqual(0)
|
expect(slateOps.length).toEqual(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not throw index error', () => {
|
||||||
|
const doc: any = { children: [] }
|
||||||
|
const target = getTarget(doc, [0, 0])
|
||||||
|
|
||||||
|
expect(target).toEqual(null)
|
||||||
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
collabBackend.destroy()
|
collabBackend.destroy()
|
||||||
server.close()
|
server.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user