Merge branch '170-adding-tests-to-cervix-temp-cases' into 'master'
Resolve "Adding tests to cervix-temp cases" Closes #170 See merge request bloodyhealth/drip!78
This commit is contained in:
+13
-4
@@ -1,16 +1,25 @@
|
|||||||
function convertToSymptoFormat(val) {
|
function convertToSymptoFormat(val) {
|
||||||
const sympto = { date: val.date }
|
const sympto = { date: val.date }
|
||||||
|
if (val.bleeding) sympto.bleeding = {
|
||||||
|
value: val.bleeding,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
if (val.temperature) sympto.temperature = {
|
if (val.temperature) sympto.temperature = {
|
||||||
value: val.temperature,
|
value: val.temperature,
|
||||||
|
time: '08:00',
|
||||||
exclude: false
|
exclude: false
|
||||||
}
|
}
|
||||||
if (val.mucus) sympto.mucus = {
|
if (val.mucus) sympto.mucus = {
|
||||||
value: val.mucus,
|
value: val.mucus,
|
||||||
exclude: false,
|
|
||||||
feeling: val.mucus,
|
feeling: val.mucus,
|
||||||
texture: val.mucus
|
texture: val.mucus,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
if (val.cervix && typeof val.cervix.opening === 'number' && typeof val.cervix.firmness === 'number') sympto.cervix = {
|
||||||
|
opening: val.cervix.opening,
|
||||||
|
firmness: val.cervix.firmness,
|
||||||
|
exclude: false
|
||||||
}
|
}
|
||||||
if (val.bleeding) sympto.bleeding = { value: val.bleeding, exclude: false }
|
|
||||||
return sympto
|
return sympto
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +84,7 @@ export const cycleWithTempAndNoMucusShift = [
|
|||||||
{ date: '2018-05-27', temperature: 36.9, mucus: 4 }
|
{ date: '2018-05-27', temperature: 36.9, mucus: 4 }
|
||||||
].map(convertToSymptoFormat).reverse()
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|
||||||
export const cycleWithFhmCervix = [
|
export const cervixShiftAndFhmOnSameDay = [
|
||||||
{ date: '2018-08-01', bleeding: 2 },
|
{ date: '2018-08-01', bleeding: 2 },
|
||||||
{ date: '2018-08-02', bleeding: 1 },
|
{ date: '2018-08-02', bleeding: 1 },
|
||||||
{ date: '2018-08-03', bleeding: 0 },
|
{ date: '2018-08-03', bleeding: 0 },
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import {
|
|||||||
cycleWithFhmMucus,
|
cycleWithFhmMucus,
|
||||||
longAndComplicatedCycleWithMucus,
|
longAndComplicatedCycleWithMucus,
|
||||||
cycleWithTempAndNoMucusShift,
|
cycleWithTempAndNoMucusShift,
|
||||||
cycleWithFhmCervix,
|
cervixShiftAndFhmOnSameDay,
|
||||||
longAndComplicatedCycleWithCervix,
|
longAndComplicatedCycleWithCervix,
|
||||||
cycleWithTempAndNoCervixShift
|
cycleWithTempAndNoCervixShift
|
||||||
} from './fixtures'
|
} from './fixtures'
|
||||||
@@ -77,7 +77,7 @@ export function fillWithMucusDummyData() {
|
|||||||
|
|
||||||
export function fillWithCervixDummyData() {
|
export function fillWithCervixDummyData() {
|
||||||
const dummyCycles = [
|
const dummyCycles = [
|
||||||
cycleWithFhmCervix,
|
cervixShiftAndFhmOnSameDay,
|
||||||
longAndComplicatedCycleWithCervix,
|
longAndComplicatedCycleWithCervix,
|
||||||
cycleWithTempAndNoCervixShift
|
cycleWithTempAndNoCervixShift
|
||||||
]
|
]
|
||||||
|
|||||||
+2
-1
@@ -23,7 +23,8 @@ export default function getSymptoThermalStatus(cycleInfo) {
|
|||||||
if (statusForLast.temperatureShift) {
|
if (statusForLast.temperatureShift) {
|
||||||
const preOvuPhase = getPreOvulatoryPhase(
|
const preOvuPhase = getPreOvulatoryPhase(
|
||||||
cycle,
|
cycle,
|
||||||
[previousCycle, ...earlierCycles]
|
[previousCycle, ...earlierCycles],
|
||||||
|
secondarySymptom
|
||||||
)
|
)
|
||||||
if (preOvuPhase) {
|
if (preOvuPhase) {
|
||||||
status.phases.preOvulatory = preOvuPhase
|
status.phases.preOvulatory = preOvuPhase
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { LocalDate } from 'js-joda'
|
import { LocalDate } from 'js-joda'
|
||||||
import getNfpStatus from './index'
|
import getNfpStatus from './index'
|
||||||
|
|
||||||
export default function (previousCycles) {
|
export default function (previousCycles, secondarySymptom) {
|
||||||
const fhms = previousCycles
|
const fhms = previousCycles
|
||||||
.map(cycle => {
|
.map(cycle => {
|
||||||
const status = getNfpStatus({ cycle })
|
const status = getNfpStatus({ cycle, secondarySymptom })
|
||||||
if (status.temperatureShift) {
|
if (status.temperatureShift) {
|
||||||
const day = status.temperatureShift.firstHighMeasurementDay
|
const day = status.temperatureShift.firstHighMeasurementDay
|
||||||
const firstCycleDayDate = LocalDate.parse(cycle[0].date)
|
const firstCycleDayDate = LocalDate.parse(cycle[0].date)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { LocalDate } from "js-joda"
|
import { LocalDate } from "js-joda"
|
||||||
import apply8DayRule from './minus-8-day-rule'
|
import apply8DayRule from './minus-8-day-rule'
|
||||||
|
|
||||||
export default function(cycle, previousCycles) {
|
export default function(cycle, previousCycles, secondarySymptom) {
|
||||||
let preOvuPhaseLength = 5
|
let preOvuPhaseLength = 5
|
||||||
|
|
||||||
const minus8DayRuleResult = apply8DayRule(previousCycles)
|
const minus8DayRuleResult = apply8DayRule(previousCycles, secondarySymptom)
|
||||||
if (minus8DayRuleResult) preOvuPhaseLength = minus8DayRuleResult
|
if (minus8DayRuleResult) preOvuPhaseLength = minus8DayRuleResult
|
||||||
|
|
||||||
const startDate = LocalDate.parse(cycle[0].date)
|
const startDate = LocalDate.parse(cycle[0].date)
|
||||||
@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) {
|
|||||||
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
|
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
|
||||||
return d.date <= preOvuEndDate
|
return d.date <= preOvuEndDate
|
||||||
})
|
})
|
||||||
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays)
|
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays, secondarySymptom)
|
||||||
// if fertile mucus or cervix occurs on the 1st cycle day, there is no pre-ovu phase
|
// if fertile mucus or cervix occurs on the 1st cycle day, there is no pre-ovu phase
|
||||||
if (!preOvulatoryDays.length) return null
|
if (!preOvulatoryDays.length) return null
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ function getDaysUntilFertileSecondarySymptom(days, secondarySymptom = 'mucus') {
|
|||||||
if (secondarySymptom === 'mucus') {
|
if (secondarySymptom === 'mucus') {
|
||||||
return day.mucus && day.mucus.value > 1
|
return day.mucus && day.mucus.value > 1
|
||||||
} else if (secondarySymptom === 'cervix') {
|
} else if (secondarySymptom === 'cervix') {
|
||||||
return day.cervix && !day.cervix.isClosedAndHard
|
return day.cervix && day.cervix.opening > 0
|
||||||
|
|| day.cervix && day.cervix.firmness > 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ function convertToSymptoFormat(val) {
|
|||||||
const sympto = { date: val.date }
|
const sympto = { date: val.date }
|
||||||
if (val.temperature) sympto.temperature = {
|
if (val.temperature) sympto.temperature = {
|
||||||
value: val.temperature,
|
value: val.temperature,
|
||||||
|
time: '08:00',
|
||||||
exclude: false
|
exclude: false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val.cervix && typeof val.cervix.opening === 'number' && typeof val.cervix.firmness === 'number') sympto.cervix = {
|
if (val.cervix && typeof val.cervix.opening === 'number' && typeof val.cervix.firmness === 'number') sympto.cervix = {
|
||||||
opening: val.cervix.opening,
|
opening: val.cervix.opening,
|
||||||
firmness: val.cervix.firmness,
|
firmness: val.cervix.firmness,
|
||||||
@@ -18,11 +18,11 @@ function convertToSymptoFormat(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const cervixShiftAndFhmOnSameDay = [
|
export const cervixShiftAndFhmOnSameDay = [
|
||||||
{ date: '2018-08-01', bleeding: 1, cervix: { opening: 1, firmness: 1 } },
|
{ date: '2018-08-01', bleeding: 1 },
|
||||||
{ date: '2018-08-02', bleeding: 2, cervix: { opening: 1, firmness: 1 } },
|
{ date: '2018-08-02', bleeding: 2 },
|
||||||
{ date: '2018-08-03', temperature: 36.6, bleeding: 2, cervix: { opening: 2, firmness: 1 } },
|
{ date: '2018-08-03', temperature: 36.6, bleeding: 2 },
|
||||||
{ date: '2018-08-04', temperature: 36.55, bleeding: 1, cervix: { opening: 2, firmness: 0 } },
|
{ date: '2018-08-04', temperature: 36.55, bleeding: 1 },
|
||||||
{ date: '2018-08-05', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
{ date: '2018-08-05', temperature: 36.6, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-08-06', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
{ date: '2018-08-06', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
{ date: '2018-08-07', temperature: 36.71, cervix: { opening: 1, firmness: 0 } },
|
{ date: '2018-08-07', temperature: 36.71, cervix: { opening: 1, firmness: 0 } },
|
||||||
{ date: '2018-08-08', temperature: 36.69, cervix: { opening: 1, firmness: 0 } },
|
{ date: '2018-08-08', temperature: 36.69, cervix: { opening: 1, firmness: 0 } },
|
||||||
@@ -99,6 +99,8 @@ export const longAndComplicatedCycle = [
|
|||||||
{ date: '2018-06-04', temperature: 36.6 },
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
{ date: '2018-06-05', temperature: 36.55 },
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-07', temperature: 36.5, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-08', temperature: 36.52, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
||||||
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 1 } },
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 1 } },
|
||||||
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||||
@@ -110,7 +112,7 @@ export const longAndComplicatedCycle = [
|
|||||||
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
{ date: '2018-06-21', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
{ date: '2018-06-21', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
{ date: '2018-06-22', temperature: 36.9, cervix: { opening: 2, firmness: 1 } },
|
{ date: '2018-06-22', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }
|
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }
|
||||||
@@ -186,3 +188,80 @@ export const fiveDayCycle = [
|
|||||||
{ date: '2018-08-01', bleeding: 2 },
|
{ date: '2018-08-01', bleeding: 2 },
|
||||||
{ date: '2018-08-03', bleeding: 3 }
|
{ date: '2018-08-03', bleeding: 3 }
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const fhmOnDay12 = [
|
||||||
|
{ 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, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-12', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-14', temperature: 36.9, 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 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const fhmOnDay15 = [
|
||||||
|
{ 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, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-11', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-12', temperature: 36.4, 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: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-16', temperature: 36.9, 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 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cycleWithEarlyCervix = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-08', temperature: 36.45, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-06-11', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-23', temperature: 36.9, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-06-24', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cycleWithCervixOnFirstDay = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-08', temperature: 36.45, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-06-11', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-23', temperature: 36.9, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-06-24', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
import getSensiplanStatus from '../../lib/sympto'
|
import getSensiplanStatus from '../../lib/sympto'
|
||||||
|
import { AssertionError } from 'assert'
|
||||||
import {
|
import {
|
||||||
cervixShiftAndFhmOnSameDay,
|
cervixShiftAndFhmOnSameDay,
|
||||||
cycleWithFhmNoCervixShift,
|
cycleWithFhmNoCervixShift,
|
||||||
cycleWithoutFhm,
|
cycleWithoutFhmNoCervixShift,
|
||||||
longCycleWithoutAnyShifts,
|
longCycleWithoutAnyShifts,
|
||||||
|
longAndComplicatedCycle,
|
||||||
tempShift3DaysAfterCervixShift,
|
tempShift3DaysAfterCervixShift,
|
||||||
cervixShift2DaysAfterTempShift,
|
cervixShift2DaysAfterTempShift,
|
||||||
noOvulationDetected,
|
noOvulationDetected,
|
||||||
fiveDayCycle
|
fiveDayCycle,
|
||||||
|
fhmOnDay12,
|
||||||
|
fhmOnDay15,
|
||||||
|
cycleWithEarlyCervix,
|
||||||
|
cycleWithCervixOnFirstDay
|
||||||
} from './cervix-temp-fixtures'
|
} from './cervix-temp-fixtures'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
@@ -19,7 +25,7 @@ describe('sympto', () => {
|
|||||||
it('with no temp or cervix shifts detects only peri-ovulatory', () => {
|
it('with no temp or cervix shifts detects only peri-ovulatory', () => {
|
||||||
const status = getSensiplanStatus({
|
const status = getSensiplanStatus({
|
||||||
cycle: longCycleWithoutAnyShifts,
|
cycle: longCycleWithoutAnyShifts,
|
||||||
previousCycle: cycleWithoutFhm,
|
previousCycle: cycleWithoutFhmNoCervixShift,
|
||||||
secondarySymptom: 'cervix'
|
secondarySymptom: 'cervix'
|
||||||
})
|
})
|
||||||
expect(Object.keys(status.phases).length).to.eql(1)
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
@@ -35,7 +41,7 @@ describe('sympto', () => {
|
|||||||
it('with temp but no cervix shift detects only peri-ovulatory', () => {
|
it('with temp but no cervix shift detects only peri-ovulatory', () => {
|
||||||
const status = getSensiplanStatus({
|
const status = getSensiplanStatus({
|
||||||
cycle: cycleWithFhmNoCervixShift,
|
cycle: cycleWithFhmNoCervixShift,
|
||||||
previousCycle: cycleWithoutFhm,
|
previousCycle: cycleWithoutFhmNoCervixShift,
|
||||||
secondarySymptom: 'cervix'
|
secondarySymptom: 'cervix'
|
||||||
})
|
})
|
||||||
expect(Object.keys(status.phases).length).to.eql(1)
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
@@ -217,5 +223,286 @@ describe('sympto', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('applying the minus-8 rule', () => {
|
||||||
|
it('shortens the pre-ovu phase if there is a previous < 13 fhm', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: [fhmOnDay12, ...Array(10).fill(fhmOnDay15)],
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
|
||||||
|
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: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-04')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-05' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-04' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-26',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('shortens pre-ovu phase with prev < 13 fhm even with < 12 cycles', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12),
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
|
||||||
|
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: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-04')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-05' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-04' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-26',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('shortens the pre-ovu phase if early fertile cervix occurs', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithEarlyCervix,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12),
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-01' },
|
||||||
|
cycleDays: cycleWithEarlyCervix
|
||||||
|
.filter(({date}) => date <= '2018-06-01')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-02' },
|
||||||
|
end: { date: '2018-06-20', time: '18:00'},
|
||||||
|
cycleDays: cycleWithEarlyCervix
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-01' && date <= '2018-06-20'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-20', time: '18:00' },
|
||||||
|
cycleDays: cycleWithEarlyCervix
|
||||||
|
.filter(({date}) => date >= '2018-06-20')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('shortens the pre-ovu phase if cervix occurs even on the first day', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithCervixOnFirstDay,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12),
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-20', time: '18:00'},
|
||||||
|
cycleDays: cycleWithCervixOnFirstDay
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-06-01' && date <= '2018-06-20'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-20', time: '18:00' },
|
||||||
|
cycleDays: cycleWithCervixOnFirstDay
|
||||||
|
.filter(({date}) => date >= '2018-06-20')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('lengthens the pre-ovu phase if >= 12 cycles with fhm > 13', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: Array(11).fill(fhmOnDay15),
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-07' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-07')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-08' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00'},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-06-08' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('does not lengthen the pre-ovu phase if < 12 cycles', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay15),
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
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: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-26',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('does not detect any pre-ovu phase if prev cycle had no fhm', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: cycleWithoutFhmNoCervixShift,
|
||||||
|
earlierCycles: [...Array(12).fill(fhmOnDay15)],
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-06-01' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-26',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('when args are wrong', () => {
|
||||||
|
it('throws when arg object is not in right format', () => {
|
||||||
|
const wrongObject = { ada: 'lovelace' }
|
||||||
|
expect(() => getSensiplanStatus(wrongObject)).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if cycle array is empty', () => {
|
||||||
|
expect(() => getSensiplanStatus({cycle: []})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if cycle days are not in right format', () => {
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
Ilike: "you"
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '01.09.2018',
|
||||||
|
bleeding: { value: 0 },
|
||||||
|
cervix: {opening: 0, firmness: 0}
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-01-01',
|
||||||
|
bleeding: { value: 'medium' },
|
||||||
|
temperature: { value: 36.6 }
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-09-01',
|
||||||
|
bleeding: { value: 0 },
|
||||||
|
temperature: { value: '36.6' }
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-09-01',
|
||||||
|
bleeding: { value: 0 },
|
||||||
|
temperature: { value: 36.6 },
|
||||||
|
cervix: {opening: 4, firmness: 18}
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-09-01',
|
||||||
|
bleeding: { value: 0 },
|
||||||
|
temperature: 37.9
|
||||||
|
}],
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if first cycle day does not have valid bleeding value', () => {
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-09-01',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}],
|
||||||
|
earlierCycles: [[{
|
||||||
|
date: '2017-09-23',
|
||||||
|
bleeding: { value: '1' }
|
||||||
|
}]]
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user