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

The state is not testable #204

Open
mahozad opened this issue Feb 19, 2024 · 2 comments
Open

The state is not testable #204

mahozad opened this issue Feb 19, 2024 · 2 comments

Comments

@mahozad
Copy link

mahozad commented Feb 19, 2024

Hey! Thanks for the great library.

I have encountered some difficulties in unit tests.
I want to place the textState in a viewModel/stateHolder or whatever it's called and be able to test it.

The first problem is that the RichTextState is not immutable as mentioned in below issue:

So, I cannot enforce the users of my state holder to change the textState only through the methods of my state holder.

The next problem is that I have the following code which is working as intended in the app but my test gives false positive (the textState.textAlign in test is Left):

val textState = RichTextState().apply {
    toggleParagraphStyle(
        currentParagraphStyle.copy(
            textAlign = TextAlign.Start
        )
    )
}

Next, being notified/reacting to textState changes is not easy which makes tests need the workaround mentioned in below issues:


Side problem:

Can you please provide a way to add link to the current selection (like how bold and italic work)?

@MohamedRejeb
Copy link
Owner

Hi, Sorry for the late reply.

Thanks for your feedback. I will work on providing those missing APIs.

@mahozad
Copy link
Author

mahozad commented Mar 24, 2024

Thank you.

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

No branches or pull requests

2 participants