Add more tests for combinations of fhm and mucus peak

This commit is contained in:
Julia Friesel
2018-07-11 13:00:16 +02:00
parent a1306cd7c5
commit 9e645ddd8e
3 changed files with 290 additions and 8 deletions
+8 -6
View File
@@ -12,23 +12,25 @@ export default function (cycleDays, tempEvalEndIndex) {
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
if (threeFollowingDays.length < 3) continue
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => day.mucus.value >= bestQuality)
const bestQualityOccurringIn3FollowingDays = threeFollowingDays.some(day => {
return day.mucus.value >= bestQuality
})
if (bestQualityOccurringIn3FollowingDays) continue
// FIXME mucus peak can be same day as first higher measurement
const cycleDayIndex = cycleDays.indexOf(day)
const relevantDays = cycleDays
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
.filter(day => day.mucus && !day.mucus.exclude)
const evaluationCompleteDay = relevantDays.length > 3 ?
relevantDays[relevantDays.length - 1] : threeFollowingDays[threeFollowingDays.length - 1]
const noBestQualityUntilEndOfTempEval = relevantDays.every(day => {
return day.mucus.value < bestQuality
})
if (relevantDays.every(day => day.mucus.value < bestQuality)) {
if (noBestQualityUntilEndOfTempEval) {
return {
detected: true,
mucusPeak: day,
evaluationCompleteDay
evaluationCompleteDay: threeFollowingDays[threeFollowingDays.length - 1]
}
}
}