Closed gregorylegarec closed 7 years ago
To ease up review, it would be nice to keep files name (contact_store.spec.js -> contact_reducer.spec.js) so we can see the diff on github. We can make all the renamings in a separate step at end of sprint.
Ok for keeping files names. Thing is I almost rewrote the whole test file from scratch.
But I see your point and I will let the same name in the next PR. :)
Please @aenario have a review, I d'like to have your opinion about differents points:
Aslo, I spent some time refactoring the part of the code in charge of mapping raw contacts to immutable contacts and raw contacts list onto an immubtable map. I choose to create a dedicated library in libs/mappers, tell me if it is ok for you.
Also, I choose to change a little bit the logic to have :
addresses
which keep all the email address of a contact. I also kept theaddress
property which store the contact primary email (it is also used to to store the email used as index).Immutable#Map#withMutations
method. I choose to keep the raw contacts to immutables logic outside, so we have to pass an array of immutables in parameter to this function. It could lead us to large lines of code but I think it is more robust for the future of the code.In my unit tests, I use to repeat code sometimes, because I find it clearer and easier to maintain, tell me if you prefer me to factorize and mutualize some parts in functinos.