Shorten pre-ovu phase when early mucus
This commit is contained in:
@@ -5,13 +5,20 @@ export default function(cycle) {
|
|||||||
const fiveDayEndDate = startDate.plusDays(4).toString()
|
const fiveDayEndDate = startDate.plusDays(4).toString()
|
||||||
const fiveDayRuleDays = cycle.slice(0, 5).filter(d => d.date <= fiveDayEndDate)
|
const fiveDayRuleDays = cycle.slice(0, 5).filter(d => d.date <= fiveDayEndDate)
|
||||||
const preOvulatoryDays = getDaysUntilFertileMucus(fiveDayRuleDays)
|
const preOvulatoryDays = getDaysUntilFertileMucus(fiveDayRuleDays)
|
||||||
|
let endDate
|
||||||
|
if (preOvulatoryDays.length === fiveDayRuleDays.length) {
|
||||||
|
endDate = fiveDayEndDate
|
||||||
|
} else {
|
||||||
|
endDate = preOvulatoryDays[preOvulatoryDays.length - 1].date
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cycleDays: preOvulatoryDays,
|
cycleDays: preOvulatoryDays,
|
||||||
start: {
|
start: {
|
||||||
date: preOvulatoryDays[0].date
|
date: preOvulatoryDays[0].date
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
date: fiveDayEndDate
|
date: endDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-1
@@ -63,6 +63,29 @@ const cycleWithTempAndNoMucusShift = [
|
|||||||
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
const cycleWithEarlyMucus = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65, mucus: 3 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
|
||||||
|
{ date: '2018-06-08', temperature: 36.45, mucus: 1 },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, mucus: 4 },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, mucus: 2 },
|
||||||
|
{ date: '2018-06-11', temperature: 36.5, mucus: 3 },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, mucus: 3 },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, mucus: 4 },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, mucus: 4 },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, mucus: 3 },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, mucus: 3 },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, mucus: 4 },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, mucus: 4 },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, mucus: 4 },
|
||||||
|
{ date: '2018-06-23', temperature: 36.9, mucus: 3 },
|
||||||
|
{ date: '2018-06-24', temperature: 36.85, mucus: 4 },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, mucus: 4 },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
const cycleWithoutAnyShifts = [
|
const cycleWithoutAnyShifts = [
|
||||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
{ date: '2018-06-02', temperature: 36.65 },
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
@@ -84,5 +107,6 @@ export {
|
|||||||
cycleWithTempAndNoMucusShift,
|
cycleWithTempAndNoMucusShift,
|
||||||
cycleWithTempShift,
|
cycleWithTempShift,
|
||||||
cycleWithoutAnyShifts,
|
cycleWithoutAnyShifts,
|
||||||
fiveDayCycle
|
fiveDayCycle,
|
||||||
|
cycleWithEarlyMucus
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
import getSensiplanStatus from '../../lib/sympto'
|
import getSensiplanStatus from '../../lib/sympto'
|
||||||
import {
|
import {
|
||||||
cycleWithoutTempShift, cycleWithTempAndMucusShift, cycleWithTempAndNoMucusShift, cycleWithTempShift, cycleWithoutAnyShifts, fiveDayCycle
|
cycleWithoutTempShift,
|
||||||
|
cycleWithTempAndMucusShift,
|
||||||
|
cycleWithTempAndNoMucusShift,
|
||||||
|
cycleWithTempShift,
|
||||||
|
cycleWithoutAnyShifts,
|
||||||
|
fiveDayCycle,
|
||||||
|
cycleWithEarlyMucus
|
||||||
} from './fixtures'
|
} from './fixtures'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
@@ -86,7 +92,24 @@ describe('sympto', () => {
|
|||||||
start: { date: '2018-06-06' }
|
start: { date: '2018-06-06' }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
it('according to 5-day-rule with shortened pre-phase', function () {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithEarlyMucus,
|
||||||
|
previousCycle: cycleWithTempShift
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.assumeFertility).to.be.true()
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: [cycleWithEarlyMucus[0]],
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-01' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithEarlyMucus.slice(1),
|
||||||
|
start: { date: '2018-06-02' }
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
describe('with shifts detects pre- and peri-ovulatory phase', function () {
|
describe('with shifts detects pre- and peri-ovulatory phase', function () {
|
||||||
it('according to 5-day-rule', function () {
|
it('according to 5-day-rule', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user