diff --git a/test/sympto/fixtures.js b/test/sympto/fixtures.js index ce096faec917fa2be2a939fc9db40f8c7cb2156a..69792d55894bada10a76ce67fc3049244f54f9d6 100644 --- a/test/sympto/fixtures.js +++ b/test/sympto/fixtures.js @@ -253,4 +253,26 @@ export const fhmOnDay15 = [ { date: '2018-06-16', temperature: 36.9, mucus: 2 }, { date: '2018-06-17', temperature: 36.9, mucus: 2 }, { date: '2018-06-18', temperature: 36.9, mucus: 2 }, +].map(convertToSymptoFormat) + +export const mucusPeakSlightlyBeforeTempShift = [ + { date: '2018-06-01', temperature: 36.6, bleeding: 2 }, + { date: '2018-06-02', temperature: 36.65 }, + { date: '2018-06-04', temperature: 36.6 }, + { date: '2018-06-07', temperature: 36.4, mucus: 1 }, + { date: '2018-06-08', temperature: 36.35, mucus: 2}, + { date: '2018-06-09', temperature: 36.4, mucus: 2}, + { date: '2018-06-10', temperature: 36.45, mucus: 2}, + { date: '2018-06-11', temperature: 36.4, mucus: 3}, + { date: '2018-06-12', temperature: 36.45, mucus: 3}, + { date: '2018-06-13', temperature: 36.45, mucus: 4}, + { date: '2018-06-14', temperature: 36.55, mucus: 3}, + { date: '2018-06-15', temperature: 36.6, mucus: 3}, + { date: '2018-06-16', temperature: 36.6, mucus: 3}, + { date: '2018-06-17', temperature: 36.55, mucus: 2}, + { date: '2018-06-18', temperature: 36.6, mucus: 1}, + { date: '2018-06-19', temperature: 36.7, mucus: 1}, + { date: '2018-06-20', temperature: 36.75, mucus: 1}, + { date: '2018-06-21', temperature: 36.8, mucus: 1}, + { date: '2018-06-22', temperature: 36.8, mucus: 1} ].map(convertToSymptoFormat) \ No newline at end of file diff --git a/test/sympto/index.spec.js b/test/sympto/index.spec.js index bbb66d49ccdc7901097ec31237654b7ae5ddd286..b9dcd9f9e8e8eaf938c883926210529ccb604858 100644 --- a/test/sympto/index.spec.js +++ b/test/sympto/index.spec.js @@ -15,7 +15,8 @@ import { mucusPeak5DaysAfterFhm, mucusPeakTwoDaysBeforeFhm, fhmOnDay12, - fhmOnDay15 + fhmOnDay15, + mucusPeakSlightlyBeforeTempShift } from './fixtures' const expect = chai.expect @@ -223,6 +224,40 @@ describe('sympto', () => { }) }) + it('another example for mucus peak before temp shift', () => { + const status = getSensiplanStatus({ + cycle: mucusPeakSlightlyBeforeTempShift, + previousCycles: [cycleWithFhm] + }) + + 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-05' }, + cycleDays: mucusPeakSlightlyBeforeTempShift + .filter(({date}) => date <= '2018-06-05') + }) + expect(status.phases.periOvulatory).to.eql({ + start: { date: '2018-06-06' }, + end: { date: '2018-06-17', time: '18:00' }, + cycleDays: mucusPeakSlightlyBeforeTempShift + .filter(({date}) => { + return date > '2018-06-05' && date <= '2018-06-17' + }) + }) + expect(status.phases.postOvulatory).to.eql({ + start: { + date: '2018-06-17', + time: '18:00' + }, + cycleDays: mucusPeakSlightlyBeforeTempShift + .filter(({date}) => date >= '2018-06-17') + }) + }) + it('with another mucus peak 5 days after fHM ignores it', () => { const status = getSensiplanStatus({ cycle: mucusPeak5DaysAfterFhm,