jeppeman / mockposable

Mocking with Jetpack Compose - stubbing and verification of Composable functions
Apache License 2.0
37 stars 3 forks source link

Simple Composable function does not get replaced #1

Closed gaara87 closed 1 year ago

gaara87 commented 1 year ago

I made a sample project + test to try out the functionality of mockking and replacing a top level composable function and it doesn't seem to work as expected

Test file - MainActivityTestKt

Repo - https://github.com/gaara87/ComposeBomTest/tree/bf22996fa1991d758fbd55e3454664c367bcac49

Verification failed: call 1 of 1: class awesome.shizzle.bomtest.MainActivityKt.Greeting(eq(Itsame), null(), eq(androidx.compose.runtime.ComposerImpl@7d63690d), any(), any())). Only one matching call to MainActivityKt(static MainActivityKt)/Greeting(String, Modifier, Composer, Int, Int) happened, but arguments are not matching:
[0]: argument: Itsame, matcher: eq(Itsame), result: +
[1]: argument: null, matcher: null(), result: +
[2]: argument: androidx.compose.runtime.ComposerImpl@24f71c2a, matcher: eq(androidx.compose.runtime.ComposerImpl@7d63690d), result: -
[3]: argument: 6, matcher: any(), result: +
[4]: argument: 2, matcher: any(), result: +

This shows that the Composer param is actually not getting matched as claimed in the readme

Screenshot 2023-03-03 at 6 19 44 PM

What am I missing?

jeppeman commented 1 year ago

Hey @gaara87 Thanks for the report. I'll look into this and get back to you.

jeppeman commented 1 year ago

@gaara87 I think I have a fix for this now. I create a PR for your example repo. Can you verify that it works from that branch? https://github.com/gaara87/ComposeBomTest/pull/1

gaara87 commented 1 year ago

Tested it locally, this works great! Thank you :) Should be safe to upgrade to a v0.2 instead of just a snapshot then :)

jeppeman commented 1 year ago

👍 Yes, I'll publish 0.2 soon