Set up failing test for minus 8 rule

This commit is contained in:
Julia Friesel
2018-07-12 11:55:42 +02:00
parent 19e880183e
commit 93ff7a0f8f
3 changed files with 57 additions and 29 deletions
+1 -1
View File
@@ -38,4 +38,4 @@ function getDaysUntilFertileMucus(days) {
return days return days
} }
function apply8DayRule() {} function apply8DayRule(previousCycles) {}
+24 -26
View File
@@ -7,17 +7,17 @@ function convertToSymptoFormat(val) {
return sympto return sympto
} }
const cycleWithTempShift = [36.6, 36.6, 36.6, 36.6, 36.6, 36.6, 36.8, 36.8, 36.8] export const cycleWithTempShift = [36.6, 36.6, 36.6, 36.6, 36.6, 36.6, 36.8, 36.8, 36.8]
.map(num => ({ date: '2018-06-01', temperature: num })) .map(num => ({ date: '2018-06-01', temperature: num }))
.map(convertToSymptoFormat) .map(convertToSymptoFormat)
cycleWithTempShift.unshift({date: '2018-05-30', bleeding: { value: 2 }}) cycleWithTempShift.unshift({date: '2018-05-30', bleeding: { value: 2 }})
const cycleWithoutTempShift = [36.6, 36.6, 36.6, 36.6, 36.6, 36.6, 36.8, 36.8] export const cycleWithoutTempShift = [36.6, 36.6, 36.6, 36.6, 36.6, 36.6, 36.8, 36.8]
.map(num => ({ date: '2018-06-01', temperature: num })) .map(num => ({ date: '2018-06-01', temperature: num }))
.map(convertToSymptoFormat) .map(convertToSymptoFormat)
cycleWithoutTempShift.unshift({date: '2018-05-30', bleeding: { value: 2 }}) cycleWithoutTempShift.unshift({date: '2018-05-30', bleeding: { value: 2 }})
const cycleWithTempAndMucusShift = [ export const cycleWithTempAndMucusShift = [
{ 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -40,7 +40,7 @@ const cycleWithTempAndMucusShift = [
{ date: '2018-06-27', temperature: 36.9, mucus: 1 } { date: '2018-06-27', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const cycleWithTempAndNoMucusShift = [ export const cycleWithTempAndNoMucusShift = [
{ 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 },
{ date: '2018-06-05', temperature: 36.55 }, { date: '2018-06-05', temperature: 36.55 },
@@ -63,7 +63,7 @@ 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 = [ export const cycleWithEarlyMucus = [
{ 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, mucus: 3 }, { date: '2018-06-02', temperature: 36.65, mucus: 3 },
{ date: '2018-06-05', temperature: 36.55 }, { date: '2018-06-05', temperature: 36.55 },
@@ -86,7 +86,7 @@ const cycleWithEarlyMucus = [
{ date: '2018-06-27', temperature: 36.9, mucus: 4 } { date: '2018-06-27', temperature: 36.9, mucus: 4 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const cycleWithoutAnyShifts = [ export 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -96,12 +96,12 @@ const cycleWithoutAnyShifts = [
{ date: '2018-06-08', temperature: 36.45, mucus: 1 } { date: '2018-06-08', temperature: 36.45, mucus: 1 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const fiveDayCycle = [ export const fiveDayCycle = [
{ date: '2018-06-01', bleeding: 2 }, { date: '2018-06-01', bleeding: 2 },
{ date: '2018-06-03', bleeding: 3 }, { date: '2018-06-03', bleeding: 3 },
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const mucusPeakAndFhmOnSameDay = [ export const mucusPeakAndFhmOnSameDay = [
{ 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -124,7 +124,7 @@ const mucusPeakAndFhmOnSameDay = [
{ date: '2018-06-27', temperature: 36.9, mucus: 1 } { date: '2018-06-27', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const fhmTwoDaysBeforeMucusPeak = [ export const fhmTwoDaysBeforeMucusPeak = [
{ 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -146,7 +146,7 @@ const fhmTwoDaysBeforeMucusPeak = [
{ date: '2018-06-26', temperature: 36.8, mucus: 1 }, { date: '2018-06-26', temperature: 36.8, mucus: 1 },
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const mucusPeakTwoDaysBeforeFhm = [ export const mucusPeakTwoDaysBeforeFhm = [
{ 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -165,7 +165,7 @@ const mucusPeakTwoDaysBeforeFhm = [
{ date: '2018-07-04', temperature: 36.8, mucus: 2 }, { date: '2018-07-04', temperature: 36.8, mucus: 2 },
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const mucusPeak5DaysAfterFhm = [ export const mucusPeak5DaysAfterFhm = [
{ 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, mucus: 2 }, { date: '2018-06-02', temperature: 36.65, mucus: 2 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -190,7 +190,7 @@ const mucusPeak5DaysAfterFhm = [
{ date: '2018-07-02', temperature: 36.9, mucus: 1 } { date: '2018-07-02', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
const fhm5DaysAfterMucusPeak = [ export const fhm5DaysAfterMucusPeak = [
{ 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 },
{ date: '2018-06-04', temperature: 36.6 }, { date: '2018-06-04', temperature: 36.6 },
@@ -213,17 +213,15 @@ const fhm5DaysAfterMucusPeak = [
{ date: '2018-06-27', temperature: 36.9, mucus: 1 } { date: '2018-06-27', temperature: 36.9, mucus: 1 }
].map(convertToSymptoFormat) ].map(convertToSymptoFormat)
export { export const fhmOnDay12 = [
cycleWithoutTempShift, { date: '2018-06-01', temperature: 36.6, bleeding: 2 },
cycleWithTempAndMucusShift, { date: '2018-06-02', temperature: 36.65 },
cycleWithTempAndNoMucusShift, { date: '2018-06-04', temperature: 36.6 },
cycleWithTempShift, { date: '2018-06-05', temperature: 36.55 },
cycleWithoutAnyShifts, { date: '2018-06-06', temperature: 36.7, mucus: 0 },
fiveDayCycle, { date: '2018-06-09', temperature: 36.5, mucus: 2 },
cycleWithEarlyMucus, { date: '2018-06-10', temperature: 36.4, mucus: 3 },
fhm5DaysAfterMucusPeak, { date: '2018-06-12', temperature: 36.8, mucus: 3 },
fhmTwoDaysBeforeMucusPeak, { date: '2018-06-14', temperature: 36.9, mucus: 2 },
mucusPeak5DaysAfterFhm, { date: '2018-06-17', temperature: 36.9, mucus: 2 },
mucusPeakAndFhmOnSameDay, ].map(convertToSymptoFormat)
mucusPeakTwoDaysBeforeFhm
}
+32 -2
View File
@@ -13,7 +13,8 @@ import {
fhmTwoDaysBeforeMucusPeak, fhmTwoDaysBeforeMucusPeak,
fhm5DaysAfterMucusPeak, fhm5DaysAfterMucusPeak,
mucusPeak5DaysAfterFhm, mucusPeak5DaysAfterFhm,
mucusPeakTwoDaysBeforeFhm mucusPeakTwoDaysBeforeFhm,
fhmOnDay12
} from './fixtures' } from './fixtures'
const expect = chai.expect const expect = chai.expect
@@ -303,7 +304,36 @@ describe('sympto', () => {
}) })
describe('applying the minus-8 rule', () => { describe('applying the minus-8 rule', () => {
it('shortens the pre-ovu phase if there is a previous <13 fhm') it('shortens the pre-ovu phase if there is a previous <13 fhm', () => {
const status = getSensiplanStatus({
cycle: cycleWithTempAndMucusShift,
previousCycles: [fhmOnDay12, cycleWithTempShift]
})
expect(status.temperatureShift).to.be.an('object')
expect(status.mucusShift).to.be.an('object')
expect(status.assumeFertility).to.be.false()
expect(Object.keys(status.phases).length).to.eql(3)
expect(status.phases.preOvulatory).to.eql({
start: { date: '2018-06-01' },
end: { date: '2018-06-04' },
cycleDays: fhm5DaysAfterMucusPeak.filter(({date}) => date <= '2018-06-04')
})
expect(status.phases.periOvulatory).to.eql({
start: { date: '2018-06-05' },
end: { date: '2018-06-17', time: '18:00' },
cycleDays: fhm5DaysAfterMucusPeak.filter(({date}) => {
return date > '2018-06-04' && date <= '2018-06-17'
})
})
expect(status.phases.postOvulatory).to.eql({
start: {
date: '2018-06-17',
time: '18:00'
},
cycleDays: fhm5DaysAfterMucusPeak.filter(({date}) => date >= '2018-06-17')
})
})
it('shortens the pre-ovu phase if there is a previous <13 fhm with less than 12 cycles') it('shortens the pre-ovu phase if there is a previous <13 fhm with less than 12 cycles')
it('shortens the pre-ovu phase if mucus occurs') it('shortens the pre-ovu phase if mucus occurs')
it('lengthens the pre-ovu phase if >= 12 cycles') it('lengthens the pre-ovu phase if >= 12 cycles')