diff --git a/test/sympto/cervix-temp-fixtures.js b/test/sympto/cervix-temp-fixtures.js index 0c8ae85..0299524 100644 --- a/test/sympto/cervix-temp-fixtures.js +++ b/test/sympto/cervix-temp-fixtures.js @@ -15,7 +15,7 @@ function convertToSymptoFormat(val) { return sympto } -export const idealCycle = [ +export const cervixShiftAndFhmOnSameDay = [ { date: '2018-08-01', bleeding: 1, cervix: { opening: 1, firmness: 1 } }, { date: '2018-08-02', bleeding: 2, cervix: { opening: 1, firmness: 1 } }, { date: '2018-08-03', temperature: 36.6, bleeding: 2, cervix: { opening: 2, firmness: 1 } }, @@ -62,7 +62,7 @@ export const cycleWithoutFhmNoCervixShift = [ { date: '2018-06-13', temperature: 36.9, cervix: { opening: 1, firmness: 1 } } ].map(convertToSymptoFormat) -export const cycleWithoutAnyShifts = [ +export const longCycleWithoutAnyShifts = [ { date: '2018-07-01', temperature: 36.65, bleeding: 1 }, { date: '2018-07-02', temperature: 36.45 }, { date: '2018-07-03', temperature: 36.65 }, @@ -114,34 +114,6 @@ export const longAndComplicatedCycle = [ { date: '2018-06-27', temperature: 36.9, cervix: { opening: 0, firmness: 0 } } ].map(convertToSymptoFormat) -export const tempAndCervixEvalEndOnSameDay = [ - { date: '2018-06-01', bleeding: 2 }, - { date: '2018-06-02', bleeding: 1 }, - { date: '2018-06-03', bleeding: 1 }, - { date: '2018-06-04', bleeding: 2 }, - { date: '2018-06-05', bleeding: 1 }, - { date: '2018-06-06', bleeding: 1 }, - { date: '2018-06-07', cervix: { opening: 2, firmness: 0 } }, - { date: '2018-06-08', temperature: 36.45, cervix: { opening: 0, firmness: 1 } }, - { date: '2018-06-09', temperature: 36.5, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-10', temperature: 36.30, cervix: { opening: 0, firmness: 1 } }, - { date: '2018-06-11', temperature: 36.30, cervix: { opening: 1, firmness: 0 } }, - { date: '2018-06-12', temperature: 36.4, cervix: { opening: 2, firmness: 1 } }, - { date: '2018-06-13', temperature: 36.3, cervix: { opening: 1, firmness: 1 } }, - { date: '2018-06-14', temperature: 36.4, cervix: { opening: 1, firmness: 1 } }, - { date: '2018-06-15', temperature: 36.8, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-16', temperature: 36.8, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-17', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-18', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-19', temperature: 36.95, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-20', temperature: 37.0, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-21', temperature: 37.0, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-22', temperature: 37.0, cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-23', cervix: { opening: 0, firmness: 0 } }, - { date: '2018-06-24', cervix: { opening: 0, firmness: 0 }}, - { date: '2018-06-25', cervix: { opening: 1, firmness: 1 } } -].map(convertToSymptoFormat) - export const tempShift3DaysAfterCervixShift = [ { date: '2018-05-08', bleeding: 3 }, { date: '2018-05-09', bleeding: 2 }, @@ -189,7 +161,7 @@ export const cervixShift2DaysAfterTempShift = [ { date: '2018-04-24', temperature: 36.75, cervix: { opening: 0, firmness: 0 } } ].map(convertToSymptoFormat) -export const noInfertilePhaseDetected = [ +export const noOvulationDetected = [ { date: '2018-03-08', bleeding: 3 }, { date: '2018-03-09', bleeding: 3 }, { date: '2018-03-10', bleeding: 3 }, diff --git a/test/sympto/cervix-temp.spec.js b/test/sympto/cervix-temp.spec.js index 6b06ddd..5ccd940 100644 --- a/test/sympto/cervix-temp.spec.js +++ b/test/sympto/cervix-temp.spec.js @@ -1,14 +1,13 @@ import chai from 'chai' import getSensiplanStatus from '../../lib/sympto' import { - idealCycle, + cervixShiftAndFhmOnSameDay, cycleWithFhmNoCervixShift, cycleWithoutFhm, - cycleWithoutAnyShifts, - tempAndCervixEvalEndOnSameDay, + longCycleWithoutAnyShifts, tempShift3DaysAfterCervixShift, cervixShift2DaysAfterTempShift, - noInfertilePhaseDetected, + noOvulationDetected, fiveDayCycle } from './cervix-temp-fixtures' @@ -19,7 +18,7 @@ describe('sympto', () => { describe('with no previous higher temp measurement', () => { it('with no temp or cervix shifts detects only peri-ovulatory', () => { const status = getSensiplanStatus({ - cycle: cycleWithoutAnyShifts, + cycle: longCycleWithoutAnyShifts, previousCycle: cycleWithoutFhm, secondarySymptom: 'cervix' }) @@ -28,7 +27,7 @@ describe('sympto', () => { phases: { periOvulatory: { start: { date: '2018-07-01' }, - cycleDays: cycleWithoutAnyShifts + cycleDays: longCycleWithoutAnyShifts } } }) @@ -51,7 +50,7 @@ describe('sympto', () => { }) it('with temp and cervix shifts detects only peri- and post-ovulatory phases', () => { const status = getSensiplanStatus({ - cycle: idealCycle, + cycle: cervixShiftAndFhmOnSameDay, previousCycle: cycleWithoutFhm, secondarySymptom: 'cervix' }) @@ -62,21 +61,21 @@ describe('sympto', () => { expect(status.phases.periOvulatory).to.eql({ start: { date: '2018-08-01' }, end: { date: '2018-08-15', time: '18:00' }, - cycleDays: idealCycle + cycleDays: cervixShiftAndFhmOnSameDay .filter(({date}) => date <= '2018-08-15') }) expect(status.phases.postOvulatory).to.eql({ start: { date: '2018-08-15', time: '18:00' }, - cycleDays: idealCycle + cycleDays: cervixShiftAndFhmOnSameDay .filter(({date}) => date >= '2018-08-15') }) }) }) describe('with previous higher temp measurement', () => { - it('with no shifts detects only peri-ovulatory in 3-day long cycle according to 5-day rule', () => { + it('with no shifts detects only peri-ovulatory in 5-day long cycle according to 5-day rule', () => { const status = getSensiplanStatus({ cycle: fiveDayCycle, - previousCycle: idealCycle, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(1) @@ -88,58 +87,58 @@ describe('sympto', () => { }) it('with no shifts detects pre- and peri-ovulatory phase according to 5-day-rule', () => { const status = getSensiplanStatus({ - cycle: cycleWithoutAnyShifts, - previousCycle: idealCycle, + cycle: longCycleWithoutAnyShifts, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(2) expect(status.phases.preOvulatory).to.eql({ - cycleDays: cycleWithoutAnyShifts + cycleDays: longCycleWithoutAnyShifts .filter(({date}) => date <= '2018-07-05'), start: { date: '2018-07-01' }, end: { date: '2018-07-05' } }) expect(status.phases.periOvulatory).to.eql({ - cycleDays: cycleWithoutAnyShifts + cycleDays: longCycleWithoutAnyShifts .filter(({date}) => date >= '2018-07-06'), start: { date: '2018-07-06' } }) }) it('with evaluation of temperature and cervix end on same day', () => { const status = getSensiplanStatus({ - cycle: tempAndCervixEvalEndOnSameDay, - previousCycle: idealCycle, + cycle: cervixShiftAndFhmOnSameDay, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(3) - expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-06-17') - expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-06-17') + expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-08-15') + expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-08-15') expect(status.phases.preOvulatory).to.eql({ - start: { date: '2018-06-01' }, - end: { date: '2018-06-05' }, - cycleDays: tempAndCervixEvalEndOnSameDay - .filter(({date}) => date <= '2018-06-05') + start: { date: '2018-08-01' }, + end: { date: '2018-08-05' }, + cycleDays: cervixShiftAndFhmOnSameDay + .filter(({date}) => date <= '2018-08-05') }) expect(status.phases.periOvulatory).to.eql({ - start: { date: '2018-06-06' }, - end: { date: '2018-06-17', time: '18:00' }, - cycleDays: tempAndCervixEvalEndOnSameDay + start: { date: '2018-08-06' }, + end: { date: '2018-08-15', time: '18:00' }, + cycleDays: cervixShiftAndFhmOnSameDay .filter(({date}) => { - return date > '2018-06-05' && date <= '2018-06-17' + return date > '2018-08-05' && date <= '2018-08-15' }) }) expect(status.phases.postOvulatory).to.eql({ - start: { date: '2018-06-17', time: '18:00' }, - cycleDays: tempAndCervixEvalEndOnSameDay - .filter(({date}) => date >= '2018-06-17') + start: { date: '2018-08-15', time: '18:00' }, + cycleDays: cervixShiftAndFhmOnSameDay + .filter(({date}) => date >= '2018-08-15') }) }) it('when temperature shift happens 3 days after cervix shift', () => { const status = getSensiplanStatus({ cycle: tempShift3DaysAfterCervixShift, - previousCycle: idealCycle, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(3) @@ -171,7 +170,7 @@ describe('sympto', () => { it('when cervix shift happens 2 days after temperature shift', () => { const status = getSensiplanStatus({ cycle: cervixShift2DaysAfterTempShift, - previousCycle: idealCycle, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(3) @@ -201,19 +200,19 @@ describe('sympto', () => { }) it('when no infertile phase can be detected', () => { const status = getSensiplanStatus({ - cycle: noInfertilePhaseDetected, - previousCycle: idealCycle, + cycle: noOvulationDetected, + previousCycle: cervixShiftAndFhmOnSameDay, secondarySymptom: 'cervix' }) expect(Object.keys(status.phases).length).to.eql(2) expect(status.phases.preOvulatory).to.eql({ - cycleDays: noInfertilePhaseDetected + 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: noInfertilePhaseDetected + cycleDays: noOvulationDetected .filter(({date}) => date > '2018-03-12'), start: { date: '2018-03-13' } })