Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samwel141 committed May 28, 2024
1 parent ed7557b commit bc67ab4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 5 additions & 1 deletion server/handlers/walletHandler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('walletRouter', () => {
it('successfully', async () => {
const getTrustRelationshipsStub = sinon
.stub(TrustService.prototype, 'getTrustRelationships')
.resolves([{ id: trustRelationshipId }]);
.resolves({result:[{ id: trustRelationshipId }], count: 1});
const res = await request(app).get(
`/wallets/${walletId}/trust_relationships?state=${TrustRelationshipEnums.ENTITY_TRUST_STATE_TYPE.requested}`,
);
Expand All @@ -118,6 +118,10 @@ describe('walletRouter', () => {
state: TrustRelationshipEnums.ENTITY_TRUST_STATE_TYPE.requested,
type: undefined,
request_type: undefined,
limit: 500,
offset: 0,
sort_by: 'created_at',
order: 'desc'
}),
).eql(true);
});
Expand Down
26 changes: 22 additions & 4 deletions server/models/Trust.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe('Trust Model', () => {
expect(trustRepositoryStub.getByFilter).calledOnceWithExactly(filter, {
limit: 10,
offset: 1,
order: undefined,
sort_by: undefined
});
});

Expand All @@ -69,6 +71,8 @@ describe('Trust Model', () => {
{
limit: 10,
offset: 1,
order: undefined,
sort_by: undefined
},
);
});
Expand All @@ -89,6 +93,8 @@ describe('Trust Model', () => {
{
limit: 10,
offset: 11,
order: undefined,
sort_by: undefined
},
);
});
Expand All @@ -109,6 +115,8 @@ describe('Trust Model', () => {
{
limit: 101,
offset: 1,
order: undefined,
sort_by: undefined
},
);
});
Expand All @@ -133,6 +141,8 @@ describe('Trust Model', () => {
{
limit: 100,
offset: 0,
order: undefined,
sort_by: undefined
},
);
});
Expand Down Expand Up @@ -268,7 +278,15 @@ describe('Trust Model', () => {
});

it('should error out -- Not supported type', async () => {
getTrustRelationshipStub.resolves();
// getTrustRelationshipStub.resolves();
getTrustRelationshipStub.resolves([
{
request_type: 'request_type',
actor_wallet_id: 'actor_wallet_id',
target_wallet_id: 'target_wallet_id',
state: TrustRelationshipEnums.ENTITY_TRUST_STATE_TYPE.requested,
},
]);
const walletId = uuid();
let error;
try {
Expand Down Expand Up @@ -746,7 +764,7 @@ describe('Trust Model', () => {
});

it('should error out -- no permission to accept', async () => {
trustRepositoryStub.getByFilter.resolves([]);
trustRepositoryStub.getByFilter.resolves({count: 0, result: []});
const trustRelationshipId = uuid();
const walletId = uuid();

Expand Down Expand Up @@ -774,9 +792,9 @@ describe('Trust Model', () => {
const trustRelationshipId = uuid();
const walletId = uuid();

trustRepositoryStub.getByFilter.resolves([
trustRepositoryStub.getByFilter.resolves({count: 1, result:[
{ originator_wallet_id: walletId, id: trustRelationshipId },
]);
]});
updateTrustStateStub.resolves('state cancelled');
const result = await trustModel.cancelTrustRequest({
trustRelationshipId,
Expand Down

0 comments on commit bc67ab4

Please sign in to comment.