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

PR: Unit tests for virtual cards backend #351

Merged
merged 74 commits into from
Nov 8, 2024

Conversation

EresDev
Copy link
Contributor

@EresDev EresDev commented Oct 24, 2024

Resolves #271

With unit tests, it also includes some renaming and refactoring to the pages functions code.

Hot to run unit tests?

git clone https://github.com/EresDevOrg/pay.ubq.fi
cd pay.ubq.fi
yarn install
yarn test:unit

QA:


 ✓ tests/unit/get-best-card.test.ts (5)
   ✓ Get best payment card (5)
     ✓ should respond with correct payment card on production
     ✓ should respond with US International Mastercard for Malta as fallback
     ✓ should respond with no payment card for unsupported country
     ✓ should respond with no payment card for low amount permit
     ✓ should respond with correct payment card for sandbox
 ✓ tests/unit/get-order.test.ts (2)
   ✓ Get payment card order (2)
     ✓ should respond with order details
     ✓ should respond with error for invalid order id
 ✓ tests/unit/get-redeem-code.test.ts (3) 1315ms
   ✓ Get payment card redeem code (3) 1303ms
     ✓ should return redeem code 792ms
     ✓ should not return redeem code to user who is not actual buyer
     ✓ should return err when transaction id is empty
 ✓ tests/unit/post-order.test.ts (16) 449ms
   ✓ Post order for a payment card (16) 443ms
     ✓ should post order on production with permit
     ✓ should return err for ordering card that is not best suited
     ✓ should return err for ordering card for unsupported blockchain
     ✓ should return err for ordering card with too low permit amount
     ✓ should return err for ordering card with too high permit amount
     ✓ should return err for ordering card with expired permit
     ✓ should return err order with tx hash that not permit2 interaction
     ✓ should return error with tx hash that is not call to permitTransferFrom
     ✓ should return error with tx hash that transfers wrong token
     ✓ should return error with tx hash that transfers to wrong treasury
     ✓ should post order with uusd
     ✓ should return err with uusd for unsupported chain
     ✓ should return err with uusd for wrong method call
     ✓ should return err with uusd for wrong treasury
     ✓ should post order on sandbox with uusd
     ✓ should post order on sandbox

 Test Files  4 passed (4)
      Tests  26 passed (26)
   Start at  06:59:49
   Duration  5.94s (transform 2.11s, setup 0ms, collect 11.11s, tests 2.16s, environment 1ms, prepare 1.54s)

Copy link
Contributor

github-actions bot commented Oct 24, 2024

Unlisted dependencies (6)

Filename unlisted
tests/unit/get-best-card.test.ts @ethersproject/units
cloudflare
tests/unit/get-order.test.ts cloudflare
tests/unit/get-redeem-code.test.ts cloudflare
tests/unit/post-order.test.ts @ethersproject/abi
cloudflare

@ubiquity-os-deployer
Copy link

ubiquity-os-deployer bot commented Oct 24, 2024

Copy link
Contributor

github-actions bot commented Oct 24, 2024

Preview Deployment
b4e98408e78a30130b0e4a93c534a69ba7e17354

@EresDev EresDev marked this pull request as ready for review November 6, 2024 12:08
@EresDev EresDev requested a review from Keyrxng as a code owner November 6, 2024 12:08
@EresDev EresDev requested review from 0x4007 and rndquu November 6, 2024 12:09
Copy link
Contributor

ubiquity-os bot commented Nov 8, 2024

@EresDev, this task has been idle for a while. Please provide an update.

@rndquu rndquu merged commit b4e9840 into ubiquity:development Nov 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit tests for virtual cards backend
2 participants