From a1eddb3cbec934d792040767e5d9a4b7732c9442 Mon Sep 17 00:00:00 2001
From: emelko <ml.kochsiek@mailbox.org>
Date: Mon, 1 Oct 2018 11:42:22 +0200
Subject: [PATCH] Adds test for mucus and temp tracking: * late mucus shift and
 therefore no postovu phase

---
 test/sympto/mucus-temp-fixtures.js | 44 ++++++++++++++++++++++++++++++
 test/sympto/mucus-temp.spec.js     | 42 +++++++++++++++++++++++++++-
 2 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/test/sympto/mucus-temp-fixtures.js b/test/sympto/mucus-temp-fixtures.js
index 29e0cf31..45e0b983 100644
--- a/test/sympto/mucus-temp-fixtures.js
+++ b/test/sympto/mucus-temp-fixtures.js
@@ -191,6 +191,50 @@ export const mucusPeakOnLastDayOfTempEval = [
   { date: '2018-06-26', temperature: 36.8, mucus: 1 },
 ].map(convertToSymptoFormat)
 
+export const mucusPeakAfterLastDayOfTempEval = [
+  { 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-05', temperature: 36.55 },
+  { date: '2018-06-06', temperature: 36.7, mucus: 0 },
+  { date: '2018-06-09', temperature: 36.5, mucus: 1 },
+  { date: '2018-06-10', temperature: 36.4, mucus: 2 },
+  { date: '2018-06-13', temperature: 36.45, mucus: 2 },
+  { date: '2018-06-14', temperature: 36.5, mucus: 2 },
+  { date: '2018-06-15', temperature: 36.55, mucus: 1 },
+  { date: '2018-06-16', temperature: 36.7, mucus: 2 },
+  { date: '2018-06-17', temperature: 36.65, mucus: 2 },
+  { date: '2018-06-18', temperature: 36.75, mucus: 2 },
+  { date: '2018-06-19', temperature: 36.8, mucus: 2 },
+  { date: '2018-06-20', temperature: 36.9, mucus: 2 },
+  { date: '2018-06-21', temperature: 36.8, mucus: 3 },
+  { date: '2018-06-22', temperature: 36.9, mucus: 2 },
+  { date: '2018-06-25', temperature: 36.9, mucus: 1 },
+  { date: '2018-06-26', temperature: 36.8, mucus: 1 },
+].map(convertToSymptoFormat)
+
+export const mucusPeakOnAndAfterLastDayOfTempEval = [
+  { 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-05', temperature: 36.55 },
+  { date: '2018-06-06', temperature: 36.7, mucus: 0 },
+  { date: '2018-06-09', temperature: 36.5, mucus: 1 },
+  { date: '2018-06-10', temperature: 36.4, mucus: 2 },
+  { date: '2018-06-13', temperature: 36.45, mucus: 2 },
+  { date: '2018-06-14', temperature: 36.5, mucus: 2 },
+  { date: '2018-06-15', temperature: 36.55, mucus: 1 },
+  { date: '2018-06-16', temperature: 36.7, mucus: 2 },
+  { date: '2018-06-17', temperature: 36.65, mucus: 2 },
+  { date: '2018-06-18', temperature: 36.75, mucus: 2 },
+  { date: '2018-06-19', temperature: 36.8, mucus: 2 },
+  { date: '2018-06-20', temperature: 36.9, mucus: 3 },
+  { date: '2018-06-21', temperature: 36.8, mucus: 3 },
+  { date: '2018-06-22', temperature: 36.9, mucus: 2 },
+  { date: '2018-06-25', temperature: 36.9, mucus: 1 },
+  { date: '2018-06-26', temperature: 36.8, mucus: 1 },
+].map(convertToSymptoFormat)
+
 export const mucusPeakTwoDaysBeforeFhm = [
   { date: '2018-06-01', temperature: 36.6, bleeding: 2 },
   { date: '2018-06-02', temperature: 36.65 },
diff --git a/test/sympto/mucus-temp.spec.js b/test/sympto/mucus-temp.spec.js
index ddc0bcb7..598c33f7 100644
--- a/test/sympto/mucus-temp.spec.js
+++ b/test/sympto/mucus-temp.spec.js
@@ -12,6 +12,8 @@ import {
   cycleWithMucusOnFirstDay,
   mucusPeakAndFhmOnSameDay,
   mucusPeakOnLastDayOfTempEval,
+  mucusPeakAfterLastDayOfTempEval,
+  mucusPeakOnAndAfterLastDayOfTempEval,
   fhm5DaysAfterMucusPeak,
   mucusPeak5DaysAfterFhm,
   mucusPeakTwoDaysBeforeFhm,
@@ -174,7 +176,7 @@ describe('sympto', () => {
         })
       })
 
-      it('with fhM 2 days before mucus peak waits for end of mucus eval', () => {
+      it('with mucus peak 3 days after fhM waits for end of mucus eval', () => {
         const status = getSensiplanStatus({
           cycle: mucusPeakOnLastDayOfTempEval,
           previousCycle: cycleWithFhm
@@ -207,6 +209,44 @@ describe('sympto', () => {
             .filter(({date}) => date >= '2018-06-25')
         })
       })
+      it('with mucus peak 4 days after fhM detects no postovu phase', () => {
+        const status = getSensiplanStatus({
+          cycle: mucusPeakAfterLastDayOfTempEval,
+          previousCycle: cycleWithFhm
+        })
+
+        expect(Object.keys(status.phases).length).to.eql(2)
+        expect(status.phases.preOvulatory).to.eql({
+          start: { date: '2018-06-01' },
+          end: { date: '2018-06-05' },
+          cycleDays: mucusPeakAfterLastDayOfTempEval
+            .filter(({date}) => date <= '2018-06-05')
+        })
+        expect(status.phases.periOvulatory).to.eql({
+          start: { date: '2018-06-06' },
+          cycleDays: mucusPeakAfterLastDayOfTempEval
+            .filter(({date}) => date > '2018-06-05')
+        })
+      })
+      it('with mucus peak 3 and 4 days after fhM detects no postovu phase', () => {
+        const status = getSensiplanStatus({
+          cycle: mucusPeakOnAndAfterLastDayOfTempEval,
+          previousCycle: cycleWithFhm
+        })
+
+        expect(Object.keys(status.phases).length).to.eql(2)
+        expect(status.phases.preOvulatory).to.eql({
+          start: { date: '2018-06-01' },
+          end: { date: '2018-06-05' },
+          cycleDays: mucusPeakOnAndAfterLastDayOfTempEval
+            .filter(({date}) => date <= '2018-06-05')
+        })
+        expect(status.phases.periOvulatory).to.eql({
+          start: { date: '2018-06-06' },
+          cycleDays: mucusPeakOnAndAfterLastDayOfTempEval
+            .filter(({date}) => date > '2018-06-05')
+        })
+      })
       it('another example for mucus peak before temp shift', () => {
         const status = getSensiplanStatus({
           cycle: mucusPeakSlightlyBeforeTempShift,
-- 
GitLab