Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore.throw error in mock #6336

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class IntersolveVisaApiService {
reference: string;
}): Promise<void> {
const uuid = generateUUIDFromSeed(reference);
const amountInCent = amountInMajorUnit * 100;
const amountInCent = Math.round(amountInMajorUnit * 100); // Math round is needed to prevent floating point errors

const transferRequestDto: TransferRequestIntersolveApiDto = {
quantity: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,24 @@ export class IntersolveVisaMockService {
},
};
}
// Return error if the amount is not an integer
// If we post a non integer to the real API, it will return a similar error
if (!Number.isInteger(amount)) {
return {
status: HttpStatus.BAD_REQUEST,
statusText: 'Bad Request',
data: {
success: false,
errors: [
{
code: 'INVALID_PARAMETERS',
description:
'The JSON value could not be converted to System.Int32',
},
],
},
};
}

return {
status: HttpStatus.OK,
Expand Down
Loading