-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
example data: Better support EVENT_NEW_MESSAGE. #4760
Commits on May 24, 2021
-
tests [nfc]: Give mkMessageAction a more regular name.
The new name `mkActionEventNewMessage` is a bit more annoyingly verbose... but it's more transparent about exactly what kind of action it produces. It also represents a completely regular way of naming such a function, suitable for use in the general example-data module `eg`.
Configuration menu - View commit details
-
Copy full SHA for 98ab361 - Browse repository at this point
Copy the full SHA 98ab361View commit details -
example data [nfc]: Move mkActionEventNewMessage here.
We already use this in one spot outside the `unread` tests, and it'd be convenient to use it in more places too.
Configuration menu - View commit details
-
Copy full SHA for b8830f8 - Browse repository at this point
Copy the full SHA b8830f8View commit details -
Configuration menu - View commit details
-
Copy full SHA for bcee392 - Browse repository at this point
Copy the full SHA bcee392View commit details -
example data: Use deepFreeze in mkActionEventNewMessage.
Small thing, not essential to do -- I'm not sure it's ever actually helped us catch a bug -- but easy, and so in this central library meant for wide reuse we make a practice of it.
Configuration menu - View commit details
-
Copy full SHA for b07ee99 - Browse repository at this point
Copy the full SHA b07ee99View commit details -
example data: Extend mkActionEventNewMessage to take options.
This will let us use it in a wider range of tests.
Configuration menu - View commit details
-
Copy full SHA for 7042192 - Browse repository at this point
Copy the full SHA 7042192View commit details -
tests: Convert to eg.mkActionEventNewMessage factory, from fragment.
In particular, drop the occasional `type: EVENT_NEW_MESSAGE` and `ownUserId: eg.selfUser.user_id`, which were already redundant with `eg.eventNewMessageActionBase`. On the other hand, there was one `ownUserId: selfUser.user_id`, referring to a *different* self-user defined in the specific test. Happily that now stands out better, making the test clearer. This should be nearly NFC; the exception is that by using `eg.mkActionEventNewMessage` we're now making sure `.message.flags` exists, as it always should on an EVENT_NEW_MESSAGE action. That change will in turn be helpful in letting us clean up the code that these tests are testing.
Configuration menu - View commit details
-
Copy full SHA for cb3f1d7 - Browse repository at this point
Copy the full SHA cb3f1d7View commit details -
example data [nfc]: Drop "action fragments" idea, in favor of factories.
As seen in the one existing example of this idea, a factory function has the advantage that it can handle subtler bits of structure: here, the fact that the `Message` object found in an `EVENT_NEW_MESSAGE` action always has a `flags` property, even though other `Message` objects don't. As demonstrated in the preceding commit, where we converted uses of `eg.eventNewMessageActionBase` en masse to `eg.mkActionEventNewMessage`, it also produces shorter code at the call site. And the types sure are simpler to describe.
Configuration menu - View commit details
-
Copy full SHA for 0690dcf - Browse repository at this point
Copy the full SHA 0690dcfView commit details -
unread: Assert
flags
present on EVENT_NEW_MESSAGE in all subreducers.This should always be true in real life (as described at the `Message` definition), and we've just fixed our tests to make it true there too. So, simplify a bit the potential paths through this code by asserting the property is there before we try to use it, rather than giving it a bogus implicit default of all flags being unset.
Configuration menu - View commit details
-
Copy full SHA for 54ae694 - Browse repository at this point
Copy the full SHA 54ae694View commit details -
flags reducer: Assert
flags
present on EVENT_NEW_MESSAGE action.Much like we did for the various `unread` sub-reducers in the previous commit, this simplifies a bit the potential paths through this code. There was a test for this impossible case; remove that. While we're here, also remove a similar impossible check on `messages` being falsy, as if we got an EVENT_UPDATE_MESSAGE_FLAGS action with no `messages` property.
Configuration menu - View commit details
-
Copy full SHA for b2433dc - Browse repository at this point
Copy the full SHA b2433dcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6327e93 - Browse repository at this point
Copy the full SHA 6327e93View commit details