woocommerce-ios icon indicating copy to clipboard operation
woocommerce-ios copied to clipboard

Add Unit Tests for checkCardPresentPaymentEligibility in OrderDetailsViewModel

Open toupper opened this issue 2 years ago • 1 comments

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 configurationLoader task injectable in OrderDetailsViewModel
  • Create a mock for that
  • Add unit tests depending on the different country case (see SimplePaymentsMethodsViewModelTests)

toupper avatar Jun 09 '22 15:06 toupper

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.CardPresentPaymentsConfiguration as SUT in the assertions.

  • Creating a Mock for CardPresentPaymentsConfiguration doesn't seem to give us much value as this has a self.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 :)

iamgabrielma avatar Aug 05 '22 06:08 iamgabrielma

Discussed this one with @toupper in a pairing session and indeed seems that this issue is currently out of date. Closing.

iamgabrielma avatar Aug 18 '22 12:08 iamgabrielma