Skip to content

Commit

Permalink
Added link listeners test back
Browse files Browse the repository at this point in the history
  • Loading branch information
fayeed committed Feb 7, 2022
1 parent dfc3115 commit 0ffc5a1
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/tests/perspective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,25 @@ export default function perspectiveTests(testContext: TestContext) {
expect(pSeenInUpdateCB.uuid).toStrictEqual(p1.uuid)
expect(pSeenInUpdateCB.name).toStrictEqual(p1.name)

// const linkAdded = jest.fn()
// // TODO: @fayeed update this
// await ad4mClient.perspective.addPerspectiveLinkListener(p1.uuid, 'link-added', linkAdded)
// const linkRemoved = jest.fn()
// await ad4mClient.perspective.addPerspectiveLinkListener(p1.uuid, 'link-removed', linkRemoved)

// const linkExpression = await ad4mClient.perspective.addLink(p1.uuid , {source: 'root', target: 'lang://123'})
// expect(linkAdded.mock.calls.length).toBe(1)
// expect(linkAdded.mock.calls[0][0]).toEqual(linkExpression)

// const updatedLinkExpression = await ad4mClient.perspective.updateLink(p1.uuid , linkExpression, {source: 'root', target: 'lang://456'})
// expect(linkAdded.mock.calls.length).toBe(2)
// expect(linkAdded.mock.calls[1][0]).toEqual(updatedLinkExpression)
// expect(linkRemoved.mock.calls.length).toBe(1)
// expect(linkRemoved.mock.calls[0][0]).toEqual(linkExpression)

// await ad4mClient.perspective.removeLink(p1.uuid , updatedLinkExpression)
// expect(linkRemoved.mock.calls.length).toBe(2)
// expect(linkRemoved.mock.calls[1][0]).toEqual(updatedLinkExpression)
const linkAdded = jest.fn()
// TODO: @fayeed update this
await ad4mClient.perspective.addPerspectiveLinkAddedListener(p1.uuid, [linkAdded])
const linkRemoved = jest.fn()
await ad4mClient.perspective.addPerspectiveLinkRemovedListener(p1.uuid, [linkRemoved])

const linkExpression = await ad4mClient.perspective.addLink(p1.uuid , {source: 'root', target: 'lang://123'})
expect(linkAdded.mock.calls.length).toBe(1)
expect(linkAdded.mock.calls[0][0]).toEqual(linkExpression)

const updatedLinkExpression = await ad4mClient.perspective.updateLink(p1.uuid , linkExpression, {source: 'root', target: 'lang://456'})
expect(linkAdded.mock.calls.length).toBe(2)
expect(linkAdded.mock.calls[1][0]).toEqual(updatedLinkExpression)
expect(linkRemoved.mock.calls.length).toBe(1)
expect(linkRemoved.mock.calls[0][0]).toEqual(linkExpression)

await ad4mClient.perspective.removeLink(p1.uuid , updatedLinkExpression)
expect(linkRemoved.mock.calls.length).toBe(2)
expect(linkRemoved.mock.calls[1][0]).toEqual(updatedLinkExpression)
})

it('can run Prolog queries', async () => {
Expand Down

0 comments on commit 0ffc5a1

Please sign in to comment.