Last active
April 15, 2018 22:26
-
-
Save martinsson/d5d5d0839a6d6c9eeca704e56ccbdac8 to your computer and use it in GitHub Desktop.
Hidden testable code 4
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
// This function needs only one test | |
function hardToTest() { | |
let data = requestExternalServer() | |
let lang = persistence.get(data.id)) | |
let langToUpdate = makeLangToUpdate(lang) | |
return persistence.update(data.id, langToUpdate) | |
} | |
// This functionc can be thouroughly tested | |
function makeLangToUpdate(versionLangs, lang) { | |
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; | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment