mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.25k stars 2.94k forks source link

Refactor FXIOS-10576 Simplify the MockStoreForMiddleware and middleware test action type unwrapping #23168

Closed ih-codes closed 1 week ago

ih-codes commented 1 week ago

:scroll: Tickets

Jira ticket Github issue

:bulb: Description

This PR simplifies the MockStoreForMiddleware a little bit (the count was redundant), which lets us improve the naming. As well, simplify our middleware test action type guards using XCTUnwrap, which throws (and cancels the test execution) if the unwrapped action is the incorrect type. That means we mark our unit tests with the throw keyword.

Demo

Here is an example of what it looks like if a test fails due to an incorrect type being dispatched to the store. Note that we can still easily use the type to access the action's variables with this method.

Screenshot 2024-11-15 at 12 32 55 PM

:pencil: Checklist

You have to check all boxes before merging

mobiletest-ci-bot commented 1 week ago
Messages
:book: Edited 3 files
:book: Created 0 files

Generated by :no_entry_sign: Danger Swift against 9b587821595414ed9d137fee02a279e17f9cb25f