Merge branch '190-bug-secondary-symptom-only-occurring-after-temp-eval-end-does-not-get-ignored-as-it-should' into 'master'

Ignore secondary symptom peak after end of temperature evaluation

Closes #190

See merge request bloodyhealth/drip!93
This commit is contained in:
Julia Friesel
2018-10-01 09:49:21 +00:00
7 changed files with 288 additions and 62 deletions
+8 -2
View File
@@ -7,6 +7,7 @@ export default function (cycleDays, tempEvalEndIndex) {
// we search for the day of cervix peak, which must:
// * have fertile cervix values
// * be followed by at least 3 days
// * must happen prior to end of temperature evaluation
// these 3 following days must all show infertile cervix values
// if everything applies we must check the days until the end of temperature evaluation
// during these relevantDays no fertile cervix must occur
@@ -19,14 +20,19 @@ export default function (cycleDays, tempEvalEndIndex) {
const threeFollowingDays = cervixDays.slice(i + 1, i + 4)
if (threeFollowingDays.length < 3) continue
// no other fertile cervix value may occur until temperature evaluation has
// been completed
const fertileCervixOccursIn3FollowingDays = threeFollowingDays.some(day => {
return !isClosedAndHard(day.cervix)
})
if (fertileCervixOccursIn3FollowingDays) continue
const cycleDayIndex = cycleDays.indexOf(day)
// if temperature evaluation has been completed an we still haven't found
// a candidate, there is no cervix shift
if (cycleDayIndex > tempEvalEndIndex) return notDetected
// no other fertile cervix value may occur until temperature evaluation has
// been completed
const relevantDays = cycleDays
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
.filter(day => day.cervix && !day.cervix.exclude)
+7 -2
View File
@@ -16,8 +16,6 @@ export default function (cycleDays, tempEvalEndIndex) {
if (day.mucus.value !== currentBestQuality) continue
// the three following days must be of lower quality
// AND no best quality day may occur until temperature evaluation has
// been completed
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
if (threeFollowingDays.length < 3) continue
@@ -27,6 +25,13 @@ export default function (cycleDays, tempEvalEndIndex) {
if (bestQualityOccursIn3FollowingDays) continue
const cycleDayIndex = cycleDays.indexOf(day)
// if temperature evaluation has been completed an we still haven't found
// a candidate, there is no mucus shift
if (cycleDayIndex > tempEvalEndIndex) return notDetected
// no best quality day may occur until temperature evaluation has
// been completed
const relevantDays = cycleDays
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
.filter(day => day.mucus && !day.mucus.exclude)
+54 -7
View File
@@ -102,15 +102,15 @@ export const longAndComplicatedCycle = [
{ date: '2018-06-07', temperature: 36.5, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-06-08', temperature: 36.52, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-10', temperature: 36.7, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-15', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-16', temperature: 36.7, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-17', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-18', temperature: 36.75, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-16', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-17', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
{ date: '2018-06-18', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-06-21', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-22', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
@@ -143,7 +143,7 @@ export const tempShift3DaysAfterCervixShift = [
{ date: '2018-05-29', bleeding: 2 }
].map(convertToSymptoFormat)
export const cervixShift2DaysAfterTempShift = [
export const cervixShift3DaysAfterTempShift = [
{ date: '2018-04-05', bleeding: 3 },
{ date: '2018-04-06', bleeding: 2 },
{ date: '2018-04-07', bleeding: 2 },
@@ -156,7 +156,7 @@ export const cervixShift2DaysAfterTempShift = [
{ date: '2018-04-14', temperature: 36.35, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-15', temperature: 36.6, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-16', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-17', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-17', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
{ date: '2018-04-18', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-19', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-20', temperature: 37.0, cervix: { opening: 0, firmness: 0 } },
@@ -165,6 +165,28 @@ export const cervixShift2DaysAfterTempShift = [
{ date: '2018-04-24', temperature: 36.75, cervix: { opening: 0, firmness: 0 } }
].map(convertToSymptoFormat)
export const cervixShift4DaysAfterTempShift = [
{ date: '2018-04-05', bleeding: 3 },
{ date: '2018-04-06', bleeding: 2 },
{ date: '2018-04-07', bleeding: 2 },
{ date: '2018-04-08', bleeding: 1 },
{ date: '2018-04-09', temperature: 36.5 },
{ date: '2018-04-10', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-11', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-12', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-13', temperature: 36.35, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-14', temperature: 36.35, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-15', temperature: 36.6, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-16', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-04-17', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
{ date: '2018-04-18', temperature: 36.8, cervix: { opening: 0, firmness: 1 } },
{ date: '2018-04-19', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-20', temperature: 37.0, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-22', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-23', temperature: 37.1, cervix: { opening: 0, firmness: 0 } },
{ date: '2018-04-24', temperature: 36.75, cervix: { opening: 0, firmness: 0 } }
].map(convertToSymptoFormat)
export const noOvulationDetected = [
{ date: '2018-03-08', bleeding: 3 },
{ date: '2018-03-09', bleeding: 3 },
@@ -265,3 +287,28 @@ export const cycleWithCervixOnFirstDay = [
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
].map(convertToSymptoFormat)
export const fertileCervixOnlyAfterEndOfTempEval = [
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
{ date: '2018-06-02', temperature: 36.65 },
{ date: '2018-06-04', temperature: 36.6 },
{ date: '2018-06-05', temperature: 36.55 },
{ date: '2018-06-06', temperature: 36.7 },
{ date: '2018-06-09', temperature: 36.5 },
{ date: '2018-06-10', temperature: 36.4 },
{ date: '2018-06-13', temperature: 36.45 },
{ date: '2018-06-14', temperature: 36.5 },
{ date: '2018-06-15', temperature: 36.55 },
{ date: '2018-06-16', temperature: 36.7 },
{ date: '2018-06-17', temperature: 36.65 },
{ date: '2018-06-18', temperature: 36.60 },
{ date: '2018-06-19', temperature: 36.8 },
{ date: '2018-06-20', temperature: 36.85 },
{ date: '2018-06-21', temperature: 36.8 },
{ date: '2018-06-22', temperature: 36.9 },
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 1, firmness: 1 }},
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 }},
{ date: '2018-06-30', temperature: 36.9, cervix: { opening: 0, firmness: 0 }},
{ date: '2018-07-01', temperature: 36.9, cervix: { opening: 0, firmness: 0 }},
{ date: '2018-07-02', temperature: 36.9, cervix: { opening: 0, firmness: 0 }}
].map(convertToSymptoFormat)
+62 -12
View File
@@ -8,13 +8,15 @@ import {
longCycleWithoutAnyShifts,
longAndComplicatedCycle,
tempShift3DaysAfterCervixShift,
cervixShift2DaysAfterTempShift,
cervixShift3DaysAfterTempShift,
cervixShift4DaysAfterTempShift,
noOvulationDetected,
fiveDayCycle,
fhmOnDay12,
fhmOnDay15,
cycleWithEarlyCervix,
cycleWithCervixOnFirstDay
cycleWithCervixOnFirstDay,
fertileCervixOnlyAfterEndOfTempEval
} from './cervix-temp-fixtures'
const expect = chai.expect
@@ -172,35 +174,82 @@ describe('sympto', () => {
.filter(({date}) => date >= '2018-05-21')
})
})
it('with cervix shift 2 days after temperature shift detects all 3 phases', () => {
it('with cervix shift 3 days after temperature shift detects all 3 phases', () => {
const status = getSensiplanStatus({
cycle: cervixShift2DaysAfterTempShift,
cycle: cervixShift3DaysAfterTempShift,
previousCycle: cervixShiftAndFhmOnSameDay,
secondarySymptom: 'cervix'
})
expect(Object.keys(status.phases).length).to.eql(3)
expect(status.temperatureShift.rule).to.eql(0)
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-04-17')
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-04-19')
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-04-20')
expect(status.phases.preOvulatory).to.eql({
cycleDays: cervixShift2DaysAfterTempShift
cycleDays: cervixShift3DaysAfterTempShift
.filter(({date}) => date <= '2018-04-09'),
start: { date: '2018-04-05' },
end: { date: '2018-04-09' }
})
expect(status.phases.periOvulatory).to.eql({
cycleDays: cervixShift2DaysAfterTempShift
cycleDays: cervixShift3DaysAfterTempShift
.filter(({date}) => {
return date >= '2018-04-10' && date <= '2018-04-19'
return date >= '2018-04-10' && date <= '2018-04-20'
}),
start: { date: '2018-04-10' },
end: { date: '2018-04-19', time: '18:00' }
end: { date: '2018-04-20', time: '18:00'}
})
expect(status.phases.postOvulatory).to.eql({
cycleDays: cervixShift2DaysAfterTempShift
.filter(({date}) => date >= '2018-04-19'),
start: { date: '2018-04-19', time: '18:00' }
cycleDays: cervixShift3DaysAfterTempShift
.filter(({date}) => date >= '2018-04-20'),
start: { date: '2018-04-20', time: '18:00' }
})
})
it('with cervix shift 4 days after temperature shift detects no post-ovulatory phase', () => {
const status = getSensiplanStatus({
cycle: cervixShift4DaysAfterTempShift,
previousCycle: cervixShiftAndFhmOnSameDay,
secondarySymptom: 'cervix'
})
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
cycleDays: cervixShift4DaysAfterTempShift
.filter(({date}) => date <= '2018-04-09'),
start: { date: '2018-04-05' },
end: { date: '2018-04-09' }
})
expect(status.phases.periOvulatory).to.eql({
cycleDays: cervixShift4DaysAfterTempShift
.filter(({date}) => {
return date >= '2018-04-10'
}),
start: { date: '2018-04-10' }
})
})
it('with fertile cervix only occurring after end of temperature evaluation ignores it', () => {
const status = getSensiplanStatus({
cycle: fertileCervixOnlyAfterEndOfTempEval,
previousCycle: cervixShiftAndFhmOnSameDay,
secondarySymptom: 'cervix'
})
expect(status.temperatureShift).to.be.undefined()
expect(status.cervixShift).to.be.undefined()
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-05' },
cycleDays: fertileCervixOnlyAfterEndOfTempEval
.filter(({date}) => date <= '2018-06-05')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-06' },
cycleDays: fertileCervixOnlyAfterEndOfTempEval
.filter(({date}) => {
return date > '2018-06-05'
})
})
})
it('with no shifts no ovulation is found detects only pre and peri-ovulatory phase', () => {
@@ -223,6 +272,7 @@ describe('sympto', () => {
})
})
})
describe('applying the minus-8 rule', () => {
it('shortens the pre-ovu phase if there is a previous < 13 fhm', () => {
const status = getSensiplanStatus({
+6 -24
View File
@@ -105,30 +105,6 @@ describe('sympto', () => {
}
})
})
it('when the cervix shift is happening after tempEvalEnd', () => {
const values = [1,1,1,1,1,2,3,3,3,3,1,1,1,1,0,0,0,0,0,0,0]
.map(turnIntoCycleDayObject)
const status = getCervixStatus(values, 10)
expect(status).to.eql({
detected: true,
cervixPeakBeforeShift: {
date: 13,
cervix: {
opening: 1,
firmness: 0,
exclude: false
}
},
evaluationCompleteDay: {
date: 16,
cervix: {
opening: 0,
firmness: 0,
exclude: false
}
}
})
})
})
describe('detects no cervix shift', () => {
@@ -144,6 +120,12 @@ describe('sympto', () => {
const status = getCervixStatus(values, 17)
expect(status).to.eql({ detected: false })
})
it('when the cervix shift is happening after tempEvalEnd', () => {
const values = [1,1,1,1,1,2,3,3,3,3,1,1,1,1,0,0,0,0,0,0,0]
.map(turnIntoCycleDayObject)
const status = getCervixStatus(values, 10)
expect(status).to.eql({ detected: false })
})
it('if no days indicate fertile cervix which could be cervix peak', () => {
const values = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]
.map(turnIntoCycleDayObject)
+73 -4
View File
@@ -169,7 +169,7 @@ export const mucusPeakAndFhmOnSameDay = [
{ date: '2018-06-27', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat)
export const fhmTwoDaysBeforeMucusPeak = [
export const mucusPeakOnLastDayOfTempEval = [
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
{ date: '2018-06-02', temperature: 36.65 },
{ date: '2018-06-04', temperature: 36.6 },
@@ -183,9 +183,53 @@ export const fhmTwoDaysBeforeMucusPeak = [
{ date: '2018-06-16', temperature: 36.7, mucus: 2 },
{ date: '2018-06-17', temperature: 36.65, mucus: 2 },
{ date: '2018-06-18', temperature: 36.75, mucus: 2 },
{ date: '2018-06-19', temperature: 36.8, mucus: 3 },
{ date: '2018-06-20', temperature: 36.85, mucus: 2 },
{ date: '2018-06-21', temperature: 36.8, mucus: 4 },
{ date: '2018-06-19', temperature: 36.8, mucus: 2 },
{ date: '2018-06-20', temperature: 36.85, mucus: 3 },
{ date: '2018-06-21', temperature: 36.8, mucus: 2 },
{ date: '2018-06-22', temperature: 36.9, mucus: 2 },
{ date: '2018-06-25', temperature: 36.9, mucus: 1 },
{ date: '2018-06-26', temperature: 36.8, mucus: 1 },
].map(convertToSymptoFormat)
export const mucusPeakAfterLastDayOfTempEval = [
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
{ date: '2018-06-02', temperature: 36.65 },
{ date: '2018-06-04', temperature: 36.6 },
{ date: '2018-06-05', temperature: 36.55 },
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
{ date: '2018-06-09', temperature: 36.5, mucus: 1 },
{ date: '2018-06-10', temperature: 36.4, mucus: 2 },
{ date: '2018-06-13', temperature: 36.45, mucus: 2 },
{ date: '2018-06-14', temperature: 36.5, mucus: 2 },
{ date: '2018-06-15', temperature: 36.55, mucus: 1 },
{ date: '2018-06-16', temperature: 36.7, mucus: 2 },
{ date: '2018-06-17', temperature: 36.65, mucus: 2 },
{ date: '2018-06-18', temperature: 36.75, mucus: 2 },
{ date: '2018-06-19', temperature: 36.8, mucus: 2 },
{ date: '2018-06-20', temperature: 36.9, mucus: 2 },
{ date: '2018-06-21', temperature: 36.8, mucus: 3 },
{ date: '2018-06-22', temperature: 36.9, mucus: 2 },
{ date: '2018-06-25', temperature: 36.9, mucus: 1 },
{ date: '2018-06-26', temperature: 36.8, mucus: 1 },
].map(convertToSymptoFormat)
export const mucusPeakOnAndAfterLastDayOfTempEval = [
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
{ date: '2018-06-02', temperature: 36.65 },
{ date: '2018-06-04', temperature: 36.6 },
{ date: '2018-06-05', temperature: 36.55 },
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
{ date: '2018-06-09', temperature: 36.5, mucus: 1 },
{ date: '2018-06-10', temperature: 36.4, mucus: 2 },
{ date: '2018-06-13', temperature: 36.45, mucus: 2 },
{ date: '2018-06-14', temperature: 36.5, mucus: 2 },
{ date: '2018-06-15', temperature: 36.55, mucus: 1 },
{ date: '2018-06-16', temperature: 36.7, mucus: 2 },
{ date: '2018-06-17', temperature: 36.65, mucus: 2 },
{ date: '2018-06-18', temperature: 36.75, mucus: 2 },
{ date: '2018-06-19', temperature: 36.8, mucus: 2 },
{ date: '2018-06-20', temperature: 36.9, mucus: 3 },
{ date: '2018-06-21', temperature: 36.8, mucus: 3 },
{ date: '2018-06-22', temperature: 36.9, mucus: 2 },
{ date: '2018-06-25', temperature: 36.9, mucus: 1 },
{ date: '2018-06-26', temperature: 36.8, mucus: 1 },
@@ -332,3 +376,28 @@ export const mucusPeakSlightlyBeforeTempShift = [
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
].map(convertToSymptoFormat)
export const mucusOnlyAfterEndOfTempEval = [
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
{ date: '2018-06-02', temperature: 36.65 },
{ date: '2018-06-04', temperature: 36.6 },
{ date: '2018-06-05', temperature: 36.55 },
{ date: '2018-06-06', temperature: 36.7 },
{ date: '2018-06-09', temperature: 36.5 },
{ date: '2018-06-10', temperature: 36.4 },
{ date: '2018-06-13', temperature: 36.45 },
{ date: '2018-06-14', temperature: 36.5 },
{ date: '2018-06-15', temperature: 36.55 },
{ date: '2018-06-16', temperature: 36.7 },
{ date: '2018-06-17', temperature: 36.65 },
{ date: '2018-06-18', temperature: 36.60 },
{ date: '2018-06-19', temperature: 36.8 },
{ date: '2018-06-20', temperature: 36.85 },
{ date: '2018-06-21', temperature: 36.8 },
{ date: '2018-06-22', temperature: 36.9 },
{ date: '2018-06-25', temperature: 36.9, mucus: 4 },
{ date: '2018-06-26', temperature: 36.8, mucus: 1 },
{ date: '2018-06-30', temperature: 36.9, mucus: 1 },
{ date: '2018-07-01', temperature: 36.9, mucus: 1 },
{ date: '2018-07-02', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat)
+78 -11
View File
@@ -11,13 +11,16 @@ import {
cycleWithEarlyMucus,
cycleWithMucusOnFirstDay,
mucusPeakAndFhmOnSameDay,
fhmTwoDaysBeforeMucusPeak,
mucusPeakOnLastDayOfTempEval,
mucusPeakAfterLastDayOfTempEval,
mucusPeakOnAndAfterLastDayOfTempEval,
fhm5DaysAfterMucusPeak,
mucusPeak5DaysAfterFhm,
mucusPeakTwoDaysBeforeFhm,
fhmOnDay12,
fhmOnDay15,
mucusPeakSlightlyBeforeTempShift
mucusPeakSlightlyBeforeTempShift,
mucusOnlyAfterEndOfTempEval
} from './mucus-temp-fixtures'
const expect = chai.expect
@@ -172,9 +175,10 @@ describe('sympto', () => {
.filter(({date}) => date >= '2018-06-21')
})
})
it('with fhM 2 days before mucus peak waits for end of mucus eval', () => {
it('with mucus peak 3 days after fhM waits for end of mucus eval', () => {
const status = getSensiplanStatus({
cycle: fhmTwoDaysBeforeMucusPeak,
cycle: mucusPeakOnLastDayOfTempEval,
previousCycle: cycleWithFhm
})
@@ -185,24 +189,62 @@ describe('sympto', () => {
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-05' },
cycleDays: fhmTwoDaysBeforeMucusPeak
cycleDays: mucusPeakOnLastDayOfTempEval
.filter(({date}) => date <= '2018-06-05')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-06' },
end: { date: '2018-06-26', time: '18:00' },
cycleDays: fhmTwoDaysBeforeMucusPeak
end: { date: '2018-06-25', time: '18:00' },
cycleDays: mucusPeakOnLastDayOfTempEval
.filter(({date}) => {
return date > '2018-06-05' && date <= '2018-06-26'
return date > '2018-06-05' && date <= '2018-06-25'
})
})
expect(status.phases.postOvulatory).to.eql({
start: {
date: '2018-06-26',
date: '2018-06-25',
time: '18:00'
},
cycleDays: fhmTwoDaysBeforeMucusPeak
.filter(({date}) => date >= '2018-06-26')
cycleDays: mucusPeakOnLastDayOfTempEval
.filter(({date}) => date >= '2018-06-25')
})
})
it('with mucus peak 4 days after fhM detects no postovu phase', () => {
const status = getSensiplanStatus({
cycle: mucusPeakAfterLastDayOfTempEval,
previousCycle: cycleWithFhm
})
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-05' },
cycleDays: mucusPeakAfterLastDayOfTempEval
.filter(({date}) => date <= '2018-06-05')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-06' },
cycleDays: mucusPeakAfterLastDayOfTempEval
.filter(({date}) => date > '2018-06-05')
})
})
it('with mucus peak 3 and 4 days after fhM detects no postovu phase', () => {
const status = getSensiplanStatus({
cycle: mucusPeakOnAndAfterLastDayOfTempEval,
previousCycle: cycleWithFhm
})
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-05' },
cycleDays: mucusPeakOnAndAfterLastDayOfTempEval
.filter(({date}) => date <= '2018-06-05')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-06' },
cycleDays: mucusPeakOnAndAfterLastDayOfTempEval
.filter(({date}) => date > '2018-06-05')
})
})
it('another example for mucus peak before temp shift', () => {
@@ -334,6 +376,31 @@ describe('sympto', () => {
.filter(({date}) => date >= '2018-06-21')
})
})
it('with mucus only occurring after end of temperature evaluation ignores it', () => {
const status = getSensiplanStatus({
cycle: mucusOnlyAfterEndOfTempEval,
previousCycle: cycleWithFhm
})
expect(status.temperatureShift).to.be.undefined()
expect(status.mucusShift).to.be.undefined()
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-05' },
cycleDays: fhm5DaysAfterMucusPeak
.filter(({date}) => date <= '2018-06-05')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-06' },
cycleDays: mucusOnlyAfterEndOfTempEval
.filter(({date}) => {
return date > '2018-06-05'
})
})
})
})
describe('applying the minus-8 rule', () => {
it('shortens the pre-ovu phase if there is a previous <13 fhm', () => {