Skip to content

Commit

Permalink
contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolfo Miranda committed Aug 23, 2023
1 parent 0ba7ca5 commit 64d3ceb
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/app/signify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,53 @@ describe('SignifyClient', () => {

})

it('Contacts', async () => {
await libsodium.ready;
const bran = "0123456789abcdefghijk"

let client = new SignifyClient(url, bran, Tier.low, boot_url)

await client.boot()
await client.connect()

let contacts = client.contacts()


await contacts.list("mygroup","company","mycompany")
let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/contacts?group=mygroup&company=mycompany')
assert.equal(lastCall[1]!.method,'GET')


await contacts.get("EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao")
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/contacts/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao')
assert.equal(lastCall[1]!.method,'GET')

let info = {
"name": "John Doe",
"company": "My Company"
}
await contacts.add("EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao",info)
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
let lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/contacts/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao')
assert.equal(lastCall[1]!.method,'POST')
assert.deepEqual(lastBody,info)

await contacts.update("EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao",info)
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/contacts/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao')
assert.equal(lastCall[1]!.method,'PUT')
assert.deepEqual(lastBody,info)

await contacts.delete("EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao")
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/contacts/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao')
assert.equal(lastCall[1]!.method,'DELETE')

})

})

0 comments on commit 64d3ceb

Please sign in to comment.