Skip to content

Commit

Permalink
PP-11681 Refactor MockClient url test condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
JFSGDS committed Mar 8, 2024
1 parent 6009de2 commit d02a386
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions app/services/clients/ledger.client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,16 @@ class MockClient {

async get (url, description) {
let dataResponse
if (url.match(/\.*\/event/)) {
dataResponse = ledgerTransactionEventsFixture
return Promise.resolve({ data: dataResponse })
}
if (url.match(/\/transaction\//)) {
dataResponse = validCreatedTransactionDetailsResponse
return Promise.resolve({ data: dataResponse })
}
if (url.match(/\/report\/transactions-summary/)) {
dataResponse = validTransactionSummaryResponse
return Promise.resolve({ data: dataResponse })
}
if (url.match(/\/agreement/)) {
dataResponse = validTransactionSummaryResponse
return Promise.resolve({ data: dataResponse })
}
if (url.match(/\/payout/)) {
dataResponse = {}
return Promise.resolve({ data: dataResponse })
}
if (url.match(/\/transaction\?account_id.*limit_total/)) {
dataResponse = validTransactionSearchResponse
return Promise.resolve({ data: dataResponse })
}

if (url.match(/\.*\/event/)) dataResponse = ledgerTransactionEventsFixture
else if (url.match(/\/transaction\//)) dataResponse = validCreatedTransactionDetailsResponse
else if (url.match(/\/report\/transactions-summary/)) dataResponse = validTransactionSummaryResponse
else if (url.match(/\/agreement/)) dataResponse = validTransactionSummaryResponse
else if (url.match(/\/payout/)) dataResponse = {}
else if (url.match(/\/transaction\?account_id.*limit_total/)) dataResponse = validTransactionSearchResponse
else dataResponse = {}

return Promise.resolve({ data: dataResponse })
}
}

Expand Down

0 comments on commit d02a386

Please sign in to comment.