fpdart icon indicating copy to clipboard operation
fpdart copied to clipboard

Test Helpers

Open ryanhanks opened this issue 2 years ago • 5 comments

Any plans to provide test helpers? Something like https://pub.dev/packages/dartz_test maybe?

ryanhanks avatar Nov 29 '22 10:11 ryanhanks

Hi @ryanhanks

Thanks for the suggestion! Indeed, fpdart internally already defines some util methods for testing.

This is definitely something planned for the near future. Meanwhile, if anyone has any suggestions feel free to leave a comment here 👍

SandroMaglione avatar Dec 05 '22 04:12 SandroMaglione

@SandroMaglione

We use those in our project. Would you be interested in me adding it as a PR including documentation?

Matcher isLeft<T>(
  final Matcher? leftMatcher,
) => ...

Matcher isRight<T>(
  final Matcher? rightMatcher,
)

Matcher isSome<T>(
  final Matcher? someMatcher,
) => ...

Matcher isNone => ...

We use them like so:

expect(
     inAppPurchasePayment.subscriptionServiceApiBuilder,
     isNone,
);
expect(
    inAppPurchasePayment.subscriptionServiceApiBuilder,
    isSome<SubscriptionV2ControllerApiBuilder>(),
);
expect(
    inAppPurchasePayment.subscriptionServiceApiBuilder,
    isSome<SubscriptionV2ControllerApiBuilder>(
        predicate(
         (final SubscriptionV2ControllerApiBuilder builder) => builder ==  exampleBuilder,
        ),
    ),
);

zellidev0 avatar Apr 08 '24 07:04 zellidev0

@zellidev0 I already set up a fpdart_test package folder. The plan would be to add a separate testing library for fpdart.

I think the methods you propose may come handy once fpdart_test will be ongoing

SandroMaglione avatar Apr 09 '24 00:04 SandroMaglione

Hey @SandroMaglione any update on the test package? Specially looking for unwrapping data from TaskEither to expect. Currently there is not clean way of doing it.

SAGARSURI avatar May 06 '24 07:05 SAGARSURI

Hey @SAGARSURI

A possible fpdart v2 is currently work in progress (#147). This will bring many changes, so I think it's better to wait for v2 before starting the work on support tooling (tests, linting)

SandroMaglione avatar May 21 '24 10:05 SandroMaglione