Adds test for:

* latest valid cervix shift
* late and therefore invalid cervix shift
This commit is contained in:
emelko
2018-10-01 08:57:22 +02:00
parent 562b1f2069
commit 855b69a349
2 changed files with 67 additions and 23 deletions
+24 -2
View File
@@ -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 },
+43 -21
View File
@@ -8,7 +8,8 @@ import {
longCycleWithoutAnyShifts,
longAndComplicatedCycle,
tempShift3DaysAfterCervixShift,
cervixShift2DaysAfterTempShift,
cervixShift3DaysAfterTempShift,
cervixShift4DaysAfterTempShift,
noOvulationDetected,
fiveDayCycle,
fhmOnDay12,
@@ -173,57 +174,59 @@ 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 no shifts no ovulation is found detects only pre and peri-ovulatory phase', () => {
it('with cervix shift 4 days after temperature shift detects no post-ovulatory phase', () => {
const status = getSensiplanStatus({
cycle: noOvulationDetected,
cycle: cervixShift4DaysAfterTempShift,
previousCycle: cervixShiftAndFhmOnSameDay,
secondarySymptom: 'cervix'
})
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
cycleDays: noOvulationDetected
.filter(({date}) => date <= '2018-03-12'),
start: { date: '2018-03-08' },
end: { date: '2018-03-12' }
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: noOvulationDetected
.filter(({date}) => date > '2018-03-12'),
start: { date: '2018-03-13' }
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,
@@ -249,6 +252,25 @@ describe('sympto', () => {
})
})
})
it('with no shifts no ovulation is found detects only pre and peri-ovulatory phase', () => {
const status = getSensiplanStatus({
cycle: noOvulationDetected,
previousCycle: cervixShiftAndFhmOnSameDay,
secondarySymptom: 'cervix'
})
expect(Object.keys(status.phases).length).to.eql(2)
expect(status.phases.preOvulatory).to.eql({
cycleDays: noOvulationDetected
.filter(({date}) => date <= '2018-03-12'),
start: { date: '2018-03-08' },
end: { date: '2018-03-12' }
})
expect(status.phases.periOvulatory).to.eql({
cycleDays: noOvulationDetected
.filter(({date}) => date > '2018-03-12'),
start: { date: '2018-03-13' }
})
})
})
describe('applying the minus-8 rule', () => {