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

Clean up and tighten UpdateMessageEvent tests #258

Merged
merged 15 commits into from
Aug 5, 2023

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Aug 4, 2023

This makes a number of small improvements to the tests for our recently-added handling of update_message events editing messages (in #238), as discussed at #256 (review) .

gnprice added 15 commits August 4, 2023 14:51
If the fetch somehow didn't get the right number of messages,
most of the subsequent tests couldn't pass anyway.
The variable and the listener that updates it are naturally
closely related, so group them together.

Then group the subsequent maybeUpdateMessage call together with
the checks that inspect that call's behavior.
The subject, or "actual", we're inspecting is the Message that
one finds in the data structure.  The thing we're checking about it
is that it is the same object as the Message we found there before.
This test is for `maybeUpdateMessage`, not `fetch`.  So it's
not its job to check that `fetch` successfully got the content
and flags and isMeMessage that we expected.

What is useful for a "before" check here, on the other hand,
is to confirm that our "after" checks aren't going to be vacuous,
by checking that the message doesn't already have the values
we'll be looking for there.  So check that instead.  Include
one for lastEditTimestamp, which was previously left out of
the "before".

A low-tech way to express this would be to keep the checks
like `.equals(oldContent)` and add assertions that oldContent
differed from newContent, and so on.  But we can do it a
bit more neatly using the `not` check.
… point

The thing we're checking in "after" is that the message has been
updated to reflect the values in the update event.  So let's
express that directly.

This also lets us do away entirely with auxiliary names for various
pieces of the update event's data.
These two cases differed only in their name, the `renderingOnly`
value in the event, and that one of them used `[0]` instead of
`.single`.  Fix the latter, parameterize, and dedupe.
Each of the test cases calls setupStore and then uses the resulting
store for just one thing, namely passing it to messageListViewWithMessages.
So just subsume the former into the latter.
@chrisbobbe
Copy link
Collaborator

Thanks, LGTM! Merged.

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

Successfully merging this pull request may close these issues.

2 participants