Skip to content

Commit

Permalink
Minor improvements to common response assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Oct 2, 2024
1 parent 52bd292 commit b93ae5d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export async function verificationSuccess({
...options
}
};
const {result, error} = await verifier.post({json: body});
const {data, error, result} = await verifier.post({json: body});
should.not.exist(error, reason || 'Expected no error from verifier.');
should.exist(result, reason || 'Expected verification to succeed.');
result.status.should.equal(
200,
reason || 'Expected HTTP status 200 for successful verification'
);
return {result, error};
return {data, result, error};
}

/**
Expand All @@ -78,11 +78,11 @@ export async function verificationFail({
...options
}
};
const {result, error} = await verifier.post({json: body});
const {data, error, result} = await verifier.post({json: body});
should.not.exist(result, reason || 'Expected no result from verifier.');
should.exist(error, reason || 'Expected verifier to error.');
shouldBeErrorResponse({response: error, reason});
return {result, error};
return {data, error, result};
}

export async function shouldFailIssuance({
Expand All @@ -100,7 +100,7 @@ export async function shouldFailIssuance({
...options
}
};
const {result, error} = await issuer.post({json: body});
const {data, error, result} = await issuer.post({json: body});
should.not.exist(result, reason || 'Expected no result from issuer.');
should.exist(error, reason || 'Expected issuer to error.');
shouldBeErrorResponse({
Expand All @@ -110,7 +110,7 @@ export async function shouldFailIssuance({
expectedStatuses: [400, 422, 500],
reason
});
return {result, error};
return {data, error, result};
}

export function expectedMultibasePrefix(cryptosuite) {
Expand Down Expand Up @@ -268,9 +268,9 @@ export function shouldBeErrorResponse({
expectedStatuses = [400, 422],
reason
}) {
should.exist(response, reason || 'Expected an Error Response. ${reason}');
should.exist(response, reason || 'Expected an Error Response.');
const {status} = response;
should.exist(status, reason || 'Expected "response.status" to exist.');
should.exist(status, reason || 'Expected "errorResponse.status" to exist.');
const statusNumber = Number.parseInt(status);
if(!expectedStatuses.includes(statusNumber)) {
const statusReason = statusReasons[statusNumber];
Expand Down

0 comments on commit b93ae5d

Please sign in to comment.