Created
April 15, 2018 22:24
-
-
Save martinsson/98339a76662dfd9a79d61db7e20f3835 to your computer and use it in GitHub Desktop.
Hidden testable code 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hardToTest() { | |
| let data = requestExternalServer() // hard to test | |
| let lang = persistence.get(data.id)) // hard to test | |
| // below pure transformation logic | |
| let langToUpdate = {}; | |
| versionsLangs.map((versionLang) => { | |
| let restPath = versionLang.entity.toRestPath(); | |
| lang.dates.langsDates.map(datePayload => { | |
| if (restPath === datePayload.langRestPath) { | |
| langToUpdate[restPath] = langToUpdate[restPath] || {}; | |
| langToUpdate[restPath].dates = datePayload.payload.dates; | |
| } | |
| }); | |
| }); | |
| // hard to test again | |
| return persistence.update(data.id, langToUpdate) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment