Detect all 3 phases
This commit is contained in:
+5
-3
@@ -18,7 +18,7 @@ export default function ({ cycle, previousCycle }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if there was no first higher measurement in the previous cycle,
|
// if there was no first higher measurement in the previous cycle,
|
||||||
// no infertile preovulatory phase may be assumed
|
// no infertile pre-ovulatory phase may be assumed
|
||||||
if (getTemperatureShift(previousCycle).detected && !cycle[0].mucus) {
|
if (getTemperatureShift(previousCycle).detected && !cycle[0].mucus) {
|
||||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle)
|
status.phases.preOvulatory = getPreOvulatoryPhase(cycle)
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ export default function ({ cycle, previousCycle }) {
|
|||||||
temperatureShift.evaluationCompleteDay.date > mucusShift.evaluationCompleteDay.date ?
|
temperatureShift.evaluationCompleteDay.date > mucusShift.evaluationCompleteDay.date ?
|
||||||
temperatureShift.evaluationCompleteDay : mucusShift.evaluationCompleteDay
|
temperatureShift.evaluationCompleteDay : mucusShift.evaluationCompleteDay
|
||||||
|
|
||||||
const prevPeriOvulatoryDays = status.phases.periOvulatory.cycleDays
|
const prevPeriOvulatoryDays = periPhase.cycleDays
|
||||||
const periOvulatoryEndIndex = prevPeriOvulatoryDays.indexOf(periOvulatoryEnd)
|
const periOvulatoryEndIndex = prevPeriOvulatoryDays.indexOf(periOvulatoryEnd)
|
||||||
|
|
||||||
status.phases.postOvulatory = {
|
status.phases.postOvulatory = {
|
||||||
@@ -56,10 +56,12 @@ export default function ({ cycle, previousCycle }) {
|
|||||||
cycleDays: prevPeriOvulatoryDays.slice(periOvulatoryEndIndex)
|
cycleDays: prevPeriOvulatoryDays.slice(periOvulatoryEndIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
status.phases.periOvulatory.cycleDays = prevPeriOvulatoryDays.slice(0, periOvulatoryEndIndex + 1)
|
periPhase.cycleDays = prevPeriOvulatoryDays.slice(0, periOvulatoryEndIndex + 1)
|
||||||
|
periPhase.end = status.phases.postOvulatory.start
|
||||||
|
|
||||||
status.mucusShift = mucusShift
|
status.mucusShift = mucusShift
|
||||||
status.temperatureShift = temperatureShift
|
status.temperatureShift = temperatureShift
|
||||||
|
status.assumeFertility = false
|
||||||
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ const cycleWithTempAndNoMucusShift = [
|
|||||||
describe('sympto', () => {
|
describe('sympto', () => {
|
||||||
describe('evaluating mucus and temperature shift together', () => {
|
describe('evaluating mucus and temperature shift together', () => {
|
||||||
describe('with no previous higher measurement', () => {
|
describe('with no previous higher measurement', () => {
|
||||||
it('with no shifts detects only periovulatory', function () {
|
it('with no shifts detects only peri-ovulatory', function () {
|
||||||
const values = [
|
const values = [
|
||||||
{ temperature: 36.6, bleeding: 2 },
|
{ temperature: 36.6, bleeding: 2 },
|
||||||
{ temperature: 36.65 },
|
{ temperature: 36.65 },
|
||||||
@@ -108,7 +108,7 @@ describe('sympto', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('with shifts detects only periovulatory and postovulatory', function () {
|
it('with shifts detects only peri-ovulatory and post-ovulatory', function () {
|
||||||
const status = getSensiplanStatus({
|
const status = getSensiplanStatus({
|
||||||
cycle: cycleWithTempAndMucusShift,
|
cycle: cycleWithTempAndMucusShift,
|
||||||
previousCycle: cycleWithoutTempShift
|
previousCycle: cycleWithoutTempShift
|
||||||
@@ -116,10 +116,11 @@ describe('sympto', () => {
|
|||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
expect(status.mucusShift).to.be.an('object')
|
expect(status.mucusShift).to.be.an('object')
|
||||||
expect(status.assumeFertility).to.be.true()
|
expect(status.assumeFertility).to.be.false()
|
||||||
expect(Object.keys(status.phases)).to.eql(['periOvulatory', 'postOvulatory'])
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
start: { date: '2018-06-01' },
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
cycleDays: cycleWithTempAndMucusShift.slice(0, 21)
|
cycleDays: cycleWithTempAndMucusShift.slice(0, 21)
|
||||||
})
|
})
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
@@ -133,14 +134,14 @@ describe('sympto', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('with previous higher measurement', () => {
|
describe('with previous higher measurement', () => {
|
||||||
describe('with no shifts detects pre- and periovulatory phase', function () {
|
describe('with no shifts detects pre- and peri-ovulatory phase', function () {
|
||||||
it('according to 5-day-rule', function () {
|
it('according to 5-day-rule', function () {
|
||||||
const status = getSensiplanStatus({
|
const status = getSensiplanStatus({
|
||||||
cycle: cycleWithTempAndNoMucusShift,
|
cycle: cycleWithTempAndNoMucusShift,
|
||||||
previousCycle: cycleWithTempShift
|
previousCycle: cycleWithTempShift
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(Object.keys(status.phases)).to.eql(['periOvulatory', 'preOvulatory'])
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
expect(status.assumeFertility).to.be.true()
|
expect(status.assumeFertility).to.be.true()
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
cycleDays: cycleWithTempAndNoMucusShift.slice(0,5),
|
cycleDays: cycleWithTempAndNoMucusShift.slice(0,5),
|
||||||
@@ -154,5 +155,31 @@ describe('sympto', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
describe('with shifts detects pre- and peri-ovulatory phase', function () {
|
||||||
|
it('according to 5-day-rule', function () {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithTempAndMucusShift,
|
||||||
|
previousCycle: cycleWithTempShift
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.assumeFertility).to.be.false()
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithTempAndMucusShift.slice(0,5),
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithTempAndMucusShift.slice(5, 21),
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00'}
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithTempAndMucusShift.slice(20),
|
||||||
|
start: { date: '2018-06-21', time: '18:00'}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user