simplify tests with transformRelayClientPayload() #341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A lot of our tests have to write data into the store before testing some other logic. However, the payloads must be manually constructed using
generateRQLFieldAlias()
. It's not a big deal, but it's annoying.So this PR adds a new module
transformClientPayload(query: RelayQuery.Node, payload: Payload): Payload
- it accepts payloads where the keys correspond to field names/aliases (which cannot be written into the store as-is), and returns an equivalent payload where keys are renamed to the serialization key of the corresponding field (which can be written to the store). See the unit test for this module for an example, and how it (slightly) simplifies tests that write to the store.I didn't convert all tests - I wanted to get feedback first.