From e5ec4bf4c44e4810694be1f2cb8d3885f1b91a00 Mon Sep 17 00:00:00 2001 From: Eric Maciel Date: Wed, 27 Jan 2021 18:31:59 -0500 Subject: [PATCH] fix: cleanup getTarget test case --- packages/client/src/client.spec.ts | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/packages/client/src/client.spec.ts b/packages/client/src/client.spec.ts index 3924cf8..89b9613 100644 --- a/packages/client/src/client.spec.ts +++ b/packages/client/src/client.spec.ts @@ -7,6 +7,7 @@ import { createDoc, SyncDoc, toJS, toSlateOp } from '@hiveteams/collab-bridge' import AutomergeCollaboration from '@hiveteams/collab-backend/lib/AutomergeCollaboration' import withIOCollaboration from './withIOCollaboration' import { AutomergeOptions, SocketIOPluginOptions } from './interfaces' +import { getTarget } from '@hiveteams/collab-bridge/src/path' const connectionSlug = 'test' const docId = `/${connectionSlug}` @@ -213,23 +214,6 @@ describe('automerge editor client tests', () => { 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(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 () => { const editor = await createCollabEditor() @@ -274,6 +258,13 @@ describe('automerge editor client tests', () => { 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(() => { collabBackend.destroy() server.close()