Skip to content

Commit

Permalink
Add endpoint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv committed Oct 20, 2023
1 parent d1d8402 commit 06eb1e0
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions packages/api-kit/tests/endpoint/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,66 @@ describe('Endpoint tests', () => {
method: 'get'
})
})

it('getMessage', async () => {
const safeMessageHash = 'safe-tx-hash'

await chai
.expect(safeApiKit.getMessage(safeMessageHash))
.to.be.eventually.deep.equals({ data: { success: true } })
chai.expect(fetchData).to.have.been.calledWith({
url: `${txServiceBaseUrl}/v1/messages/${safeMessageHash}/`,
method: 'get'
})
})

it('getMessages', async () => {
const safeAddress = 'safe-address'

await chai
.expect(safeApiKit.getMessages(safeAddress))
.to.be.eventually.deep.equals({ data: { success: true } })
chai.expect(fetchData).to.have.been.calledWith({
url: `${txServiceBaseUrl}/v1/safes/${safeAddress}/messages/`,
method: 'get'
})
})

it('addMessage', async () => {
const safeAddress = 'safe-address'
const data = {
message: 'message',
signature: '0x'
}

await chai
.expect(safeApiKit.addMessage(safeAddress, data))
.to.be.eventually.deep.equals({ data: { success: true } })
chai.expect(fetchData).to.have.been.calledWith({
url: `${txServiceBaseUrl}/v1/safes/${safeAddress}/messages/`,
method: 'post',
body: {
...data,
safeAppId: 0
}
})
})

it('addMessageSignature', async () => {
const safeMessageHash = 'safe-message-hash'
const signature = '0xSignature'

await chai
.expect(safeApiKit.addMessageSignature(safeMessageHash, signature))
.to.be.eventually.deep.equals({ data: { success: true } })
chai.expect(fetchData).to.have.been.calledWith({
url: `${txServiceBaseUrl}/v1/messages/${safeMessageHash}/signatures/`,
method: 'post',
body: {
signature
}
})
})
})

describe('Custom endpoint', () => {
Expand Down

0 comments on commit 06eb1e0

Please sign in to comment.