woocommerce-ios
woocommerce-ios copied to clipboard
Add Unit Tests for checkCardPresentPaymentEligibility in OrderDetailsViewModel
Describe the bug
On this PR we removed the unit tests relative to checkCardPresentPaymentEligibility in https://github.com/woocommerce/woocommerce-ios/pull/7063/commits/902cfd1454539cdd535e664803ae8b4f01d53e06 because we couldn't inject/mock the configuration loader. To keep that PR small, I create this issue to accomplish that.
Tasks
- Make the
configurationLoadertask injectable inOrderDetailsViewModel - Create a mock for that
- Add unit tests depending on the different country case (see
SimplePaymentsMethodsViewModelTests)
Hi @toupper! While checking this issue again, I'm a bit confused of what we should test or mock, and I wonder if the issue is still valid since was created, as had been a bunch of changes. Let me know if I missed something or I'm reading it wrong, but as far as I understand the current setup:
-
CardPresentPaymentTests is already testing card present payment eligibility by using
Order.CardPresentPaymentsConfigurationas SUT in the assertions. -
Creating a
MockforCardPresentPaymentsConfigurationdoesn't seem to give us much value as this has aself.init()that already creates the object with all values for us, based uniquely in the country that is passed as a parameter, as we do not pass any other variable. -
This
self.init()implementation is also tested separately in CardPresentConfigurationTests.
Because of these I believe we can close this issue at the moment, but let know if I missed anything :)
Discussed this one with @toupper in a pairing session and indeed seems that this issue is currently out of date. Closing.