Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellenn-A committed Jan 9, 2024
1 parent a6ad4f6 commit 4a02f0d
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/unit/outofband.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ConnectionRecord,
OutOfBandInvitation,
ConnectionInvitationMessage,
ReceiveOutOfBandImplicitInvitationConfig,
} from '@aries-framework/core'
import type { Express } from 'express'

Expand Down Expand Up @@ -285,6 +286,60 @@ describe('OutOfBandController', () => {
).equals(true)
})
})
describe('Receive out of band implicit invitation', () => {
const config: ReceiveOutOfBandImplicitInvitationConfig = {
did: 'z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL',
}
test('should return out of band invitation', async () => {
const receiveImplicitInvitationStub = stub(bobAgent.oob, 'receiveImplicitInvitation')
receiveImplicitInvitationStub.resolves({
outOfBandRecord: outOfBandRecord,
connectionRecord: connectionRecord,
})
const getResult = () => receiveImplicitInvitationStub.firstCall.returnValue

const response = await request(app).post('/oob/receive-implicit-invitation').send(config) //use barebones config

expect(response.statusCode).to.be.equal(200)
expect(response.body).to.deep.equal(objectToJson(await getResult()))
})
test('should use parameters', async () => {
const receiveImplicitInvitationStub = stub(bobAgent.oob, 'receiveImplicitInvitation')
receiveImplicitInvitationStub.resolves({
outOfBandRecord: outOfBandRecord,
connectionRecord: connectionRecord,
})

// todo: add tests for routing param
const params = {
label: 'test',
alias: 'test',
imageUrl: 'test',
autoAcceptInvitation: false,
autoAcceptConnection: false,
}

const response = await request(app)
.post('/oob/receive-implicit-invitation')
.send({
...config, //send config only containing did
...params,
})

expect(response.statusCode).to.be.equal(200)
expect(
receiveImplicitInvitationStub.calledWith(
match({
label: params.label,
alias: params.alias,
imageUrl: params.imageUrl,
autoAcceptInvitation: params.autoAcceptInvitation,
autoAcceptConnection: params.autoAcceptConnection,
})
)
).equals(true)
})
})

describe('Receive out of band invitation by url', () => {
test('should return out of band invitation', async () => {
Expand Down

0 comments on commit 4a02f0d

Please sign in to comment.