dirty-chai
This commit is contained in:
@@ -1,314 +0,0 @@
|
||||
function convertToSymptoFormat(val) {
|
||||
const sympto = { date: val.date }
|
||||
if (val.temperature) sympto.temperature = {
|
||||
value: val.temperature,
|
||||
time: '08:00',
|
||||
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
|
||||
}
|
||||
|
||||
export const cervixShiftAndFhmOnSameDay = [
|
||||
{ date: '2018-08-01', bleeding: 1 },
|
||||
{ date: '2018-08-02', bleeding: 2 },
|
||||
{ date: '2018-08-03', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-08-04', temperature: 36.55, bleeding: 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-07', temperature: 36.71, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-08-08', temperature: 36.69, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-08-09', temperature: 36.64, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-08-10', temperature: 36.66, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-08-11', temperature: 36.61, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-08-12', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-08-13', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-08-14', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-08-15', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-08-16', temperature: 36.95, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-08-17', temperature: 36.95, cervix: { opening: 0, firmness: 0 } }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithFhmNoCervixShift = [
|
||||
{ date: '2018-08-01', bleeding: 1 },
|
||||
{ date: '2018-08-02', bleeding: 2 },
|
||||
{ date: '2018-08-03', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-08-04', temperature: 36.55, bleeding: 1 },
|
||||
{ date: '2018-08-05', temperature: 36.6 },
|
||||
{ date: '2018-08-06', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-08-07', temperature: 36.7, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-08-08', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-08-09', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-08-10', temperature: 36.85, cervix: { opening: 2, firmness: 0 } },
|
||||
{ date: '2018-08-11', temperature: 36.9, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-08-12', temperature: 36.95, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-08-13', temperature: 36.95, cervix: { opening: 0, firmness: 0 } }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithoutFhmNoCervixShift = [
|
||||
{ date: '2018-06-02', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-06-03', 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.8 },
|
||||
{ date: '2018-06-10', temperature: 36.9, cervix: { opening: 2, firmness: 0 } },
|
||||
{ date: '2018-06-13', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
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 },
|
||||
{ date: '2018-07-04', temperature: 36.65 },
|
||||
{ date: '2018-07-05', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-07-06', temperature: 36.85, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-07-07', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-08', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-07-09', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-07-10', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-11', temperature: 36.35, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-07-12', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-07-13', temperature: 36.25, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-14', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-15', temperature: 36.65, cervix: { opening: 2, firmness: 0 } },
|
||||
{ date: '2018-07-16', temperature: 36.15, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-07-17', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-07-18', temperature: 36.25, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-07-19', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-20', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-21', temperature: 36.52, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-07-22', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-23', temperature: 36.75, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-24', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-07-25', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-07-26', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const longAndComplicatedCycle = [
|
||||
{ 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-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-10', temperature: 36.7, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, 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.5, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-06-17', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
||||
{ date: '2018-06-18', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||
{ 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-21', temperature: 36.8, cervix: { opening: 1, 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-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const tempShift3DaysAfterCervixShift = [
|
||||
{ date: '2018-05-08', bleeding: 3 },
|
||||
{ date: '2018-05-09', bleeding: 2 },
|
||||
{ date: '2018-05-10', bleeding: 2 },
|
||||
{ date: '2018-05-11', bleeding: 1 },
|
||||
{ date: '2018-05-12', temperature: 36.3 },
|
||||
{ date: '2018-05-13', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-05-14', temperature: 36.3, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-05-15', temperature: 36.2, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-05-16', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-17', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-18', temperature: 36.35, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-19', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-20', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-21', temperature: 36.6, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-22', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-23', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-05-24', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-25', temperature: 36.95, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-05-26', temperature: 36.85, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-05-27', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-05-28', temperature: 36.6, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-05-29', bleeding: 2 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cervixShift3DaysAfterTempShift = [
|
||||
{ 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: 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 } },
|
||||
{ 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 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 },
|
||||
{ date: '2018-03-10', bleeding: 3 },
|
||||
{ date: '2018-03-11', bleeding: 3 },
|
||||
{ date: '2018-03-12', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-03-13', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-14', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-15', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-16', temperature: 36.2, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-17', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-18', temperature: 36.6, cervix: { opening: 1, firmness: 1 } },
|
||||
{ date: '2018-03-19', temperature: 36.35, cervix: { opening: 1, firmness: 0 } },
|
||||
{ date: '2018-03-20', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-03-21', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||
{ date: '2018-03-22', temperature: 36.7, cervix: { opening: 0, firmness: 1 } },
|
||||
{ date: '2018-03-23', temperature: 36.7, cervix: { opening: 0, firmness: 0 } }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const fiveDayCycle = [
|
||||
{ date: '2018-08-01', bleeding: 2 },
|
||||
{ date: '2018-08-03', bleeding: 3 }
|
||||
].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)
|
||||
|
||||
export const fertileCervixOnlyAfterEndOfTempEval = [
|
||||
{ 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 },
|
||||
{ date: '2018-06-09', temperature: 36.5 },
|
||||
{ date: '2018-06-10', temperature: 36.4 },
|
||||
{ date: '2018-06-13', temperature: 36.45 },
|
||||
{ date: '2018-06-14', temperature: 36.5 },
|
||||
{ date: '2018-06-15', temperature: 36.55 },
|
||||
{ date: '2018-06-16', temperature: 36.7 },
|
||||
{ date: '2018-06-17', temperature: 36.65 },
|
||||
{ date: '2018-06-18', temperature: 36.60 },
|
||||
{ date: '2018-06-19', temperature: 36.8 },
|
||||
{ date: '2018-06-20', temperature: 36.85 },
|
||||
{ date: '2018-06-21', temperature: 36.8 },
|
||||
{ date: '2018-06-22', temperature: 36.9 },
|
||||
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 1, firmness: 1 }},
|
||||
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 }},
|
||||
{ date: '2018-06-30', temperature: 36.9, cervix: { opening: 0, firmness: 0 }},
|
||||
{ date: '2018-07-01', temperature: 36.9, cervix: { opening: 0, firmness: 0 }},
|
||||
{ date: '2018-07-02', temperature: 36.9, cervix: { opening: 0, firmness: 0 }}
|
||||
].map(convertToSymptoFormat)
|
||||
@@ -1,558 +0,0 @@
|
||||
import chai from 'chai'
|
||||
import getSensiplanStatus from '../../lib/sympto'
|
||||
import { AssertionError } from 'assert'
|
||||
import {
|
||||
cervixShiftAndFhmOnSameDay,
|
||||
cycleWithFhmNoCervixShift,
|
||||
cycleWithoutFhmNoCervixShift,
|
||||
longCycleWithoutAnyShifts,
|
||||
longAndComplicatedCycle,
|
||||
tempShift3DaysAfterCervixShift,
|
||||
cervixShift3DaysAfterTempShift,
|
||||
cervixShift4DaysAfterTempShift,
|
||||
noOvulationDetected,
|
||||
fiveDayCycle,
|
||||
fhmOnDay12,
|
||||
fhmOnDay15,
|
||||
cycleWithEarlyCervix,
|
||||
cycleWithCervixOnFirstDay,
|
||||
fertileCervixOnlyAfterEndOfTempEval
|
||||
} from './cervix-temp-fixtures'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('combining temperature and cervix tracking', () => {
|
||||
describe('with no previous higher temp measurement', () => {
|
||||
it('with no temp or cervix shifts detects only peri-ovulatory', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longCycleWithoutAnyShifts,
|
||||
previousCycle: cycleWithoutFhmNoCervixShift,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(1)
|
||||
expect(status).to.eql({
|
||||
phases: {
|
||||
periOvulatory: {
|
||||
start: { date: '2018-07-01' },
|
||||
cycleDays: longCycleWithoutAnyShifts
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
it('with temp but no cervix shift detects only peri-ovulatory', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithFhmNoCervixShift,
|
||||
previousCycle: cycleWithoutFhmNoCervixShift,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(1)
|
||||
expect(status).to.eql({
|
||||
phases: {
|
||||
periOvulatory: {
|
||||
start: { date: '2018-08-01' },
|
||||
cycleDays: cycleWithFhmNoCervixShift
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
it('with temp and cervix shifts at the same day an no previous cycle detects only peri- and post-ovulatory phases', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||
expect(status.temperatureShift.rule).to.eql(0)
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-08-01' },
|
||||
end: { date: '2018-08-15', time: '18:00' },
|
||||
cycleDays: cervixShiftAndFhmOnSameDay
|
||||
.filter(({date}) => date <= '2018-08-15')
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: { date: '2018-08-15', time: '18:00' },
|
||||
cycleDays: cervixShiftAndFhmOnSameDay
|
||||
.filter(({date}) => date >= '2018-08-15')
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('with previous higher temp measurement', () => {
|
||||
it('with no shifts in 5-day long cycle detects only peri-ovulatory according to 5-day rule', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: fiveDayCycle,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(1)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
cycleDays: fiveDayCycle,
|
||||
start: { date: '2018-08-01' },
|
||||
end: { date: '2018-08-05' }
|
||||
})
|
||||
})
|
||||
it('with no shifts in long cycle detects pre- and peri-ovulatory phase according to 5-day-rule', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longCycleWithoutAnyShifts,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
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: longCycleWithoutAnyShifts
|
||||
.filter(({date}) => date >= '2018-07-06'),
|
||||
start: { date: '2018-07-06' }
|
||||
})
|
||||
})
|
||||
it('with temperature and cervix evaluation end on same day detects all 3 phases', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cervixShiftAndFhmOnSameDay,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(3)
|
||||
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-08-01' },
|
||||
end: { date: '2018-08-05' },
|
||||
cycleDays: cervixShiftAndFhmOnSameDay
|
||||
.filter(({date}) => date <= '2018-08-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-08-06' },
|
||||
end: { date: '2018-08-15', time: '18:00' },
|
||||
cycleDays: cervixShiftAndFhmOnSameDay
|
||||
.filter(({date}) => {
|
||||
return date > '2018-08-05' && date <= '2018-08-15'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: { date: '2018-08-15', time: '18:00' },
|
||||
cycleDays: cervixShiftAndFhmOnSameDay
|
||||
.filter(({date}) => date >= '2018-08-15')
|
||||
})
|
||||
})
|
||||
it('with temperature shift 3 days after cervix shift detects all 3 phases', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: tempShift3DaysAfterCervixShift,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(3)
|
||||
expect(status.cervixShift).to.be.an('object')
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-05-18')
|
||||
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-05-21')
|
||||
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
start: { date: '2018-05-08' },
|
||||
end: { date: '2018-05-12' },
|
||||
cycleDays: tempShift3DaysAfterCervixShift
|
||||
.filter(({date}) => date <= '2018-05-12')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date:'2018-05-13'},
|
||||
end: { date: '2018-05-21', time: '18:00' },
|
||||
cycleDays: tempShift3DaysAfterCervixShift
|
||||
.filter(({date}) => {
|
||||
return date >= '2018-05-13' && date <= '2018-05-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: { date: '2018-05-21', time: '18:00' },
|
||||
cycleDays: tempShift3DaysAfterCervixShift
|
||||
.filter(({date}) => date >= '2018-05-21')
|
||||
})
|
||||
})
|
||||
it('with cervix shift 3 days after temperature shift detects all 3 phases', () => {
|
||||
const status = getSensiplanStatus({
|
||||
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-20')
|
||||
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
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: cervixShift3DaysAfterTempShift
|
||||
.filter(({date}) => {
|
||||
return date >= '2018-04-10' && date <= '2018-04-20'
|
||||
}),
|
||||
start: { date: '2018-04-10' },
|
||||
end: { date: '2018-04-20', time: '18:00'}
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
cycleDays: cervixShift3DaysAfterTempShift
|
||||
.filter(({date}) => date >= '2018-04-20'),
|
||||
start: { date: '2018-04-20', time: '18:00' }
|
||||
})
|
||||
})
|
||||
it('with cervix shift 4 days after temperature shift detects no post-ovulatory phase', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cervixShift4DaysAfterTempShift,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
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: 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,
|
||||
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||
secondarySymptom: 'cervix'
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.undefined()
|
||||
expect(status.cervixShift).to.be.undefined()
|
||||
|
||||
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: fertileCervixOnlyAfterEndOfTempEval
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
cycleDays: fertileCervixOnlyAfterEndOfTempEval
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05'
|
||||
})
|
||||
})
|
||||
})
|
||||
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', () => {
|
||||
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)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,147 +0,0 @@
|
||||
import chai from 'chai'
|
||||
import getCervixStatus from '../../lib/sympto/cervix'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
function turnIntoCycleDayObject(value, fakeDate) {
|
||||
const hardAndClosed = {
|
||||
opening: 0,
|
||||
firmness: 0
|
||||
}
|
||||
const hardAndOpen = {
|
||||
opening: 1,
|
||||
firmness: 0
|
||||
}
|
||||
const softAndClosed = {
|
||||
opening: 0,
|
||||
firmness: 1
|
||||
}
|
||||
const softAndOpen = {
|
||||
opening: 1,
|
||||
firmness: 1
|
||||
}
|
||||
const cervixStates = [hardAndClosed, hardAndOpen, softAndClosed, softAndOpen]
|
||||
return {
|
||||
date: fakeDate,
|
||||
cervix: {
|
||||
opening: cervixStates[value].opening,
|
||||
firmness: cervixStates[value].firmness,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('detects cervix shift', () => {
|
||||
it('when shift happens at day 13 with consistent following days of infertile cervix until tempEvalEnd', () => {
|
||||
const values = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 16)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 10,
|
||||
cervix: {
|
||||
opening: 1,
|
||||
firmness: 1,
|
||||
exclude: false
|
||||
}
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 13,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
it('right at the start of cycle days even if later shift happens again because tempEvalEnd happened before second potential shift', () => {
|
||||
const values = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 5)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 0,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 1,
|
||||
exclude: false
|
||||
},
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 3,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
it('at day 6 although right at the start of cycle days a potential shift happened but because tempEvalEnd happens after second shift', () => {
|
||||
const values = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 10)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 6,
|
||||
cervix: {
|
||||
opening: 1,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
},
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 9,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('detects no cervix shift', () => {
|
||||
it('if there are less than 3 days closed and hard cervix', () => {
|
||||
const values = [0, 0, 0, 1, 1, 1, 2, 0, 3, 3, 3, 1, 1, 1, 0, 0, 2, 0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 15)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if cycleDays have not enough cervix values to detect valid cervix shift', () => {
|
||||
const values = [2,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 17)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('when the cervix shift is happening after tempEvalEnd', () => {
|
||||
const values = [1,1,1,1,1,2,3,3,3,3,1,1,1,1,0,0,0,0,0,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 10)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if no days indicate fertile cervix which could be cervix peak', () => {
|
||||
const values = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 12)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if all days indicate infertile cervix values', () => {
|
||||
const values = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 9)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if there are no cervix values', () => {
|
||||
const values = [].map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values, 15)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,403 +0,0 @@
|
||||
function convertToSymptoFormat(val) {
|
||||
const sympto = { date: val.date }
|
||||
if (val.temperature) sympto.temperature = {
|
||||
value: val.temperature,
|
||||
exclude: false
|
||||
}
|
||||
if (val.mucus) sympto.mucus = {
|
||||
value: val.mucus,
|
||||
exclude: false
|
||||
}
|
||||
if (val.bleeding) sympto.bleeding = {
|
||||
value: val.bleeding,
|
||||
exclude: false
|
||||
}
|
||||
return sympto
|
||||
}
|
||||
|
||||
export const cycleWithFhm = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-13', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-16', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 37.0, mucus: 2 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithoutFhm = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 37.0, mucus: 2 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const longAndComplicatedCycle = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 4 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 1 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 2 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithTempAndNoMucusShift = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-08', temperature: 36.55, mucus: 1 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-11', temperature: 36.6, mucus: 3 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 4 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-23', temperature: 37.0, mucus: 3 },
|
||||
{ date: '2018-06-24', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 4 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithEarlyMucus = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-08', temperature: 36.55, mucus: 1 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-11', temperature: 36.6, mucus: 3 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 4 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-23', temperature: 37.0, mucus: 3 },
|
||||
{ date: '2018-06-24', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 4 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithMucusOnFirstDay = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2, mucus: 3},
|
||||
{ date: '2018-06-02', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-08', temperature: 36.55, mucus: 1 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-11', temperature: 36.6, mucus: 3 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 4 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-23', temperature: 37.0, mucus: 3 },
|
||||
{ date: '2018-06-24', temperature: 36.95, mucus: 4 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 4 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const cycleWithoutAnyShifts = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-07', temperature: 36.85, mucus: 0 },
|
||||
{ date: '2018-06-08', temperature: 36.55, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const fiveDayCycle = [
|
||||
{ date: '2018-06-01', bleeding: 2 },
|
||||
{ date: '2018-06-03', bleeding: 3 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakAndFhmOnSameDay = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 4 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-20', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakOnLastDayOfTempEval = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 1 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 2 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 2 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 1 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 3 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakAfterLastDayOfTempEval = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 1 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 2 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 2 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 1 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-20', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakOnAndAfterLastDayOfTempEval = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 1 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 2 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 2 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 1 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-20', temperature: 37.0, mucus: 3 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakTwoDaysBeforeFhm = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65, mucus: 2 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 4 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 4 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 2 },
|
||||
{ date: '2018-07-02', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-07-03', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-07-04', temperature: 36.9, mucus: 2 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeak5DaysAfterFhm = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75, mucus: 2 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 3 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 3 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.70, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 2 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-30', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-07-01', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-07-02', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const highestMucusQualityAfterEndOfEval = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75, mucus: 2 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 1 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 3 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 3 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.70, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 3 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
{ date: '2018-06-30', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-07-01', temperature: 37.0, mucus: 4 },
|
||||
{ date: '2018-07-02', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const fhm5DaysAfterMucusPeak = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 2 },
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 36.6, mucus: 4 },
|
||||
{ date: '2018-06-15', temperature: 36.65, mucus: 3 },
|
||||
{ date: '2018-06-16', temperature: 36.8, mucus: 3 },
|
||||
{ date: '2018-06-17', temperature: 36.75, mucus: 3 },
|
||||
{ date: '2018-06-18', temperature: 36.85, mucus: 2 },
|
||||
{ date: '2018-06-19', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-20', temperature: 36.95, mucus: 2 },
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 2 },
|
||||
{ date: '2018-06-22', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 4 },
|
||||
{ date: '2018-06-27', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const fhmOnDay12 = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 2 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 3 },
|
||||
{ date: '2018-06-12', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-14', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 37.0, mucus: 2 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const fhmOnDay15 = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8, mucus: 0 },
|
||||
{ date: '2018-06-09', temperature: 36.6, mucus: 2 },
|
||||
{ date: '2018-06-10', temperature: 36.5, mucus: 3 },
|
||||
{ date: '2018-06-15', temperature: 36.9, mucus: 3 },
|
||||
{ date: '2018-06-16', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-17', temperature: 37.0, mucus: 2 },
|
||||
{ date: '2018-06-18', temperature: 37.0, mucus: 2 },
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusPeakSlightlyBeforeTempShift = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-07', temperature: 36.5, mucus: 1 },
|
||||
{ date: '2018-06-08', temperature: 36.45, mucus: 2},
|
||||
{ date: '2018-06-09', temperature: 36.5, mucus: 2},
|
||||
{ date: '2018-06-10', temperature: 36.55, mucus: 2},
|
||||
{ date: '2018-06-11', temperature: 36.5, mucus: 3},
|
||||
{ date: '2018-06-12', temperature: 36.55, mucus: 3},
|
||||
{ date: '2018-06-13', temperature: 36.55, mucus: 4},
|
||||
{ date: '2018-06-14', temperature: 36.65, mucus: 3},
|
||||
{ date: '2018-06-15', temperature: 36.7, mucus: 3},
|
||||
{ date: '2018-06-16', temperature: 36.7, mucus: 3},
|
||||
{ date: '2018-06-17', temperature: 36.65, mucus: 2},
|
||||
{ date: '2018-06-18', temperature: 36.7, mucus: 1},
|
||||
{ date: '2018-06-19', temperature: 36.8, mucus: 1},
|
||||
{ date: '2018-06-20', temperature: 36.85, mucus: 1},
|
||||
{ date: '2018-06-21', temperature: 36.9, mucus: 1},
|
||||
{ date: '2018-06-22', temperature: 36.9, mucus: 1}
|
||||
].map(convertToSymptoFormat)
|
||||
|
||||
export const mucusOnlyAfterEndOfTempEval = [
|
||||
{ date: '2018-06-01', temperature: 36.7, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.75 },
|
||||
{ date: '2018-06-04', temperature: 36.7 },
|
||||
{ date: '2018-06-05', temperature: 36.65 },
|
||||
{ date: '2018-06-06', temperature: 36.8 },
|
||||
{ date: '2018-06-09', temperature: 36.6 },
|
||||
{ date: '2018-06-10', temperature: 36.5 },
|
||||
{ date: '2018-06-13', temperature: 36.55 },
|
||||
{ date: '2018-06-14', temperature: 36.6 },
|
||||
{ date: '2018-06-15', temperature: 36.65 },
|
||||
{ date: '2018-06-16', temperature: 36.8 },
|
||||
{ date: '2018-06-17', temperature: 36.75 },
|
||||
{ date: '2018-06-18', temperature: 36.70 },
|
||||
{ date: '2018-06-19', temperature: 36.9 },
|
||||
{ date: '2018-06-20', temperature: 36.95 },
|
||||
{ date: '2018-06-21', temperature: 36.9 },
|
||||
{ date: '2018-06-22', temperature: 37.0 },
|
||||
{ date: '2018-06-25', temperature: 37.0, mucus: 4 },
|
||||
{ date: '2018-06-26', temperature: 36.9, mucus: 1 },
|
||||
{ date: '2018-06-30', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-07-01', temperature: 37.0, mucus: 1 },
|
||||
{ date: '2018-07-02', temperature: 37.0, mucus: 1 }
|
||||
].map(convertToSymptoFormat)
|
||||
@@ -1,661 +0,0 @@
|
||||
import chai from 'chai'
|
||||
import getSensiplanStatus from '../../lib/sympto'
|
||||
import { AssertionError } from 'assert'
|
||||
import {
|
||||
cycleWithoutFhm,
|
||||
longAndComplicatedCycle,
|
||||
cycleWithTempAndNoMucusShift,
|
||||
cycleWithFhm,
|
||||
cycleWithoutAnyShifts,
|
||||
fiveDayCycle,
|
||||
cycleWithEarlyMucus,
|
||||
cycleWithMucusOnFirstDay,
|
||||
mucusPeakAndFhmOnSameDay,
|
||||
mucusPeakOnLastDayOfTempEval,
|
||||
mucusPeakAfterLastDayOfTempEval,
|
||||
mucusPeakOnAndAfterLastDayOfTempEval,
|
||||
fhm5DaysAfterMucusPeak,
|
||||
mucusPeak5DaysAfterFhm,
|
||||
mucusPeakTwoDaysBeforeFhm,
|
||||
fhmOnDay12,
|
||||
fhmOnDay15,
|
||||
mucusPeakSlightlyBeforeTempShift,
|
||||
mucusOnlyAfterEndOfTempEval
|
||||
} from './mucus-temp-fixtures'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('combining temperature and mucus tracking', () => {
|
||||
describe('with no previous higher temp measurement', () => {
|
||||
it('with no shifts detects only peri-ovulatory', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithoutAnyShifts,
|
||||
previousCycle: cycleWithoutFhm
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
cycleDays: cycleWithoutAnyShifts
|
||||
})
|
||||
})
|
||||
it('with temp and mucus shifts detects only peri-ovulatory and post-ovulatory', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
previousCycle: cycleWithoutFhm
|
||||
})
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).to.be.an('object')
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date <= '2018-06-21')
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
describe('with previous higher measurement', () => {
|
||||
describe('with no shifts detects pre-ovulatory phase', () => {
|
||||
it('according to 5-day-rule', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: fiveDayCycle,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(1)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
cycleDays: fiveDayCycle,
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-05' }
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('with no shifts detects pre- and peri-ovulatory phase', () => {
|
||||
it('according to 5-day-rule', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithTempAndNoMucusShift,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
cycleDays: cycleWithTempAndNoMucusShift
|
||||
.filter(({date}) => date <= '2018-06-05'),
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-05' }
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
cycleDays: cycleWithTempAndNoMucusShift
|
||||
.filter(({date}) => date > '2018-06-05'),
|
||||
start: { date: '2018-06-06' }
|
||||
})
|
||||
})
|
||||
it('according to 5-day-rule with shortened pre-phase', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithEarlyMucus,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
cycleDays: [cycleWithEarlyMucus[0]],
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-01' }
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
cycleDays: cycleWithEarlyMucus.slice(1),
|
||||
start: { date: '2018-06-02' }
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('with shifts detects pre- and peri-ovulatory phase', () => {
|
||||
it('according to 5-day-rule', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(Object.keys(status.phases).length).to.eql(3)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date <= '2018-06-05'),
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-05' }
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date > '2018-06-05' && date <= '2018-06-21'),
|
||||
start: { date: '2018-06-06' },
|
||||
end: { date: '2018-06-21', time: '18:00'}
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21'),
|
||||
start: { date: '2018-06-21', time: '18:00'}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('combining first higher measurment and mucus peak', () => {
|
||||
it('with fhM + mucus peak on same day finds start of postovu phase', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: mucusPeakAndFhmOnSameDay,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-05' },
|
||||
cycleDays: mucusPeakAndFhmOnSameDay
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
end: { date: '2018-06-21', time: '18:00' },
|
||||
cycleDays: mucusPeakAndFhmOnSameDay
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: mucusPeakAndFhmOnSameDay
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
|
||||
it('with mucus peak 3 days after fhM waits for end of mucus eval', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: mucusPeakOnLastDayOfTempEval,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-05' },
|
||||
cycleDays: mucusPeakOnLastDayOfTempEval
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
end: { date: '2018-06-25', time: '18:00' },
|
||||
cycleDays: mucusPeakOnLastDayOfTempEval
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05' && date <= '2018-06-25'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-25',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: mucusPeakOnLastDayOfTempEval
|
||||
.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,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-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,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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: mucusPeak5DaysAfterFhm
|
||||
.filter(({date}) => date <= '2018-06-01')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-02' },
|
||||
end: { date: '2018-06-22', time: '18:00' },
|
||||
cycleDays: mucusPeak5DaysAfterFhm
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-01' && date <= '2018-06-22'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-22',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: mucusPeak5DaysAfterFhm
|
||||
.filter(({date}) => date >= '2018-06-22')
|
||||
})
|
||||
})
|
||||
it('with mucus peak 2 days before fhM waits for end of temp eval', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: mucusPeakTwoDaysBeforeFhm,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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: mucusPeakTwoDaysBeforeFhm
|
||||
.filter(({date}) => date <= '2018-06-04')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-05' },
|
||||
end: { date: '2018-07-03', time: '18:00' },
|
||||
cycleDays: mucusPeakTwoDaysBeforeFhm
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-04' && date <= '2018-07-03'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-07-03',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: mucusPeakTwoDaysBeforeFhm
|
||||
.filter(({date}) => date >= '2018-07-03')
|
||||
})
|
||||
})
|
||||
it('with mucus peak 5 days before fhM waits for end of temp eval', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: fhm5DaysAfterMucusPeak,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-05' },
|
||||
cycleDays: fhm5DaysAfterMucusPeak
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
end: { date: '2018-06-21', time: '18:00' },
|
||||
cycleDays: fhm5DaysAfterMucusPeak
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: fhm5DaysAfterMucusPeak
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
|
||||
it('with mucus only occurring after end of temperature evaluation ignores it', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: mucusOnlyAfterEndOfTempEval,
|
||||
previousCycle: cycleWithFhm
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.undefined()
|
||||
expect(status.mucusShift).to.be.undefined()
|
||||
|
||||
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: fhm5DaysAfterMucusPeak
|
||||
.filter(({date}) => date <= '2018-06-05')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-06' },
|
||||
cycleDays: mucusOnlyAfterEndOfTempEval
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05'
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
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)]
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-04' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
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)
|
||||
})
|
||||
|
||||
expect(status.temperatureShift).to.be.an('object')
|
||||
expect(status.mucusShift).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-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-04' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
it('shortens the pre-ovu phase if mucus occurs', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithEarlyMucus,
|
||||
previousCycle: fhmOnDay12,
|
||||
earlierCycles: Array(10).fill(fhmOnDay12)
|
||||
})
|
||||
|
||||
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.preOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-01' },
|
||||
cycleDays: cycleWithEarlyMucus
|
||||
.filter(({date}) => date <= '2018-06-01')
|
||||
})
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-02' },
|
||||
cycleDays: cycleWithEarlyMucus
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-01'
|
||||
})
|
||||
})
|
||||
})
|
||||
it('shortens the pre-ovu phase if mucus occurs even on the first day', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: cycleWithMucusOnFirstDay,
|
||||
previousCycle: fhmOnDay12,
|
||||
earlierCycles: Array(10).fill(fhmOnDay12)
|
||||
})
|
||||
|
||||
|
||||
expect(Object.keys(status.phases).length).to.eql(1)
|
||||
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
cycleDays: cycleWithMucusOnFirstDay
|
||||
})
|
||||
})
|
||||
it('lengthens the pre-ovu phase if >= 12 cycles with fhm > 13', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
previousCycle: fhmOnDay15,
|
||||
earlierCycles: Array(11).fill(fhmOnDay15)
|
||||
})
|
||||
|
||||
|
||||
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-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-07' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
it('does not lengthen the pre-ovu phase if < 12 cycles', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
previousCycle: fhmOnDay15,
|
||||
earlierCycles: Array(10).fill(fhmOnDay15)
|
||||
})
|
||||
|
||||
|
||||
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-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => {
|
||||
return date > '2018-06-05' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
it('does not detect any pre-ovu phase if prev cycle had no fhm', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
previousCycle: cycleWithoutFhm,
|
||||
earlierCycles: [...Array(12).fill(fhmOnDay15)]
|
||||
})
|
||||
|
||||
|
||||
expect(Object.keys(status.phases).length).to.eql(2)
|
||||
expect(status.phases.periOvulatory).to.eql({
|
||||
start: { date: '2018-06-01' },
|
||||
end: { date: '2018-06-21', time: '18:00' },
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => {
|
||||
return date >= '2018-06-01' && date <= '2018-06-21'
|
||||
})
|
||||
})
|
||||
expect(status.phases.postOvulatory).to.eql({
|
||||
start: {
|
||||
date: '2018-06-21',
|
||||
time: '18:00'
|
||||
},
|
||||
cycleDays: longAndComplicatedCycle
|
||||
.filter(({date}) => date >= '2018-06-21')
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('when args are wrong', () => {
|
||||
it('throws when arg object is not in right format', () => {
|
||||
const wrongObject = { hello: 'world' }
|
||||
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: [{
|
||||
hello: 'world',
|
||||
bleeding: { value: 0 }
|
||||
}],
|
||||
earlierCycles: [[{
|
||||
date: '1992-09-09',
|
||||
bleeding: { value: 0 }
|
||||
}]]
|
||||
})).to.throw(AssertionError)
|
||||
expect(() => getSensiplanStatus({
|
||||
cycle: [{
|
||||
date: '2018-04-13',
|
||||
temperature: {value: '35'},
|
||||
bleeding: { value: 0 }
|
||||
}],
|
||||
earlierCycles: [[{
|
||||
date: '1992-09-09',
|
||||
bleeding: { value: 0 }
|
||||
}]]
|
||||
})).to.throw(AssertionError)
|
||||
expect(() => getSensiplanStatus({
|
||||
cycle: [{
|
||||
date: '09-14-2017',
|
||||
bleeding: { value: 0 }
|
||||
}],
|
||||
earlierCycles: [[{
|
||||
date: '1992-09-09',
|
||||
bleeding: { value: 0 }
|
||||
}]]
|
||||
})).to.throw(AssertionError)
|
||||
})
|
||||
it('throws if first cycle day does not have bleeding value', () => {
|
||||
expect(() => getSensiplanStatus({
|
||||
cycle: [{
|
||||
date: '2017-01-01',
|
||||
bleeding: {
|
||||
value: 'medium'
|
||||
}
|
||||
}],
|
||||
earlierCycles: [[
|
||||
{
|
||||
date: '2017-09-23',
|
||||
}
|
||||
]]
|
||||
})).to.throw(AssertionError)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,80 +0,0 @@
|
||||
import chai from 'chai'
|
||||
import getMucusStatus from '../../lib/sympto/mucus'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
function turnIntoCycleDayObject(value, fakeDate) {
|
||||
return {
|
||||
mucus : { value },
|
||||
date: fakeDate
|
||||
}
|
||||
}
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('detect mucus shift', () => {
|
||||
describe('regular rule', () => {
|
||||
it('detects mucus shift correctly', function () {
|
||||
const values = [0,0,0,1,1,2,2,2,3,3,3,2,2,0,1,1,1,1,0,0,0,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getMucusStatus(values, 12)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
mucusPeak: {
|
||||
date: 10,
|
||||
mucus: { value: 3 }
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 13,
|
||||
mucus: { value: 0 }
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('detects no mucus shift when there are less than 3 days of lower quality', function () {
|
||||
const values = [0, 1, 1, 2, 0, 0, 1, 2, 3, 2, 3, 3, 3, 2, 2]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getMucusStatus(values, 30)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects no mucus shift when there are no mucus values', function () {
|
||||
const status = getMucusStatus(Array(10).fill({
|
||||
date: 1,
|
||||
temperature: { value: 35 }
|
||||
}))
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects no mucus shift when the mucus values are all the same', function () {
|
||||
const values = [2, 2, 2, 2, 2, 2, 2, 2]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getMucusStatus(values, 30)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects no mucus shift when mucus only changes from dry to nothing', function () {
|
||||
const values = [0,0,0,1,0,0,0,0,0,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getMucusStatus(values, 30)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('ignores an early seeming shift from 0 to 1', function () {
|
||||
const values = [0,0,0,1,0,0,0,2,3,3,3,2,2,0,1,1,1,1,0,0,0,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getMucusStatus(values, 12)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
mucusPeak: {
|
||||
date: 10,
|
||||
mucus: { value: 3 }
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 13,
|
||||
mucus: { value: 0 }
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,272 +0,0 @@
|
||||
import chai from 'chai'
|
||||
import getTemperatureStatus from '../../lib/sympto/temperature'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
function turnIntoCycleDayObject(value, fakeDate) {
|
||||
return {
|
||||
temperature : { value },
|
||||
date: fakeDate
|
||||
}
|
||||
}
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('detect temperature shift', () => {
|
||||
describe('regular rule', () => {
|
||||
it('reports lower temperature status before shift', () => {
|
||||
const lowerTemps = [36.7, 36.57, 36.47, 36.49, 36.57]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(lowerTemps)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects temperature shift correctly', () => {
|
||||
const tempShift =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(tempShift)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 7,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 9,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
rule: 0
|
||||
})
|
||||
})
|
||||
|
||||
it('detects temperature shift correctly with drop after third high temp', () => {
|
||||
const tempShift =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8, 36.4]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(tempShift)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 7,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 9,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
rule: 0
|
||||
})
|
||||
})
|
||||
|
||||
it('detects no temperature shift when there are no 6 low temps', () => {
|
||||
const tempShift = [36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(tempShift)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects no temperature shift if the shift is not high enough', () => {
|
||||
const tempShift =
|
||||
[36.57, 36.7, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(tempShift)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects missing temperature shift correctly', () => {
|
||||
const noTempShift =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.77]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(noTempShift)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects shift after an earlier one was invalid', () => {
|
||||
const temps =
|
||||
[36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4,
|
||||
36.7, 36.8, 36.9]
|
||||
.map(turnIntoCycleDayObject)
|
||||
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 10,
|
||||
temperature: { value: 36.7 }
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 12,
|
||||
temperature: { value: 36.9 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 0
|
||||
})
|
||||
})
|
||||
|
||||
it('detects 2 consecutive invalid shifts', () => {
|
||||
const temps =
|
||||
[36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4,
|
||||
36.6, 36.6, 36.7]
|
||||
.map(turnIntoCycleDayObject)
|
||||
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
})
|
||||
|
||||
describe('1st exception rule', () => {
|
||||
it('detects temperature shift', () => {
|
||||
const firstException =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55,
|
||||
36.8, 36.86, 36.77, 36.63]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(firstException)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 7,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
|
||||
evaluationCompleteDay: {
|
||||
date: 10,
|
||||
temperature : { value: 36.63 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 1
|
||||
})
|
||||
})
|
||||
|
||||
it('detects missing temperature shift correctly', () => {
|
||||
const firstExceptionNoShift =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55,
|
||||
36.8, 36.86, 36.77, 36.57]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(firstExceptionNoShift)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects missing temperature shift with not enough high temps', () => {
|
||||
const temps =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.77]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({ detected: false })
|
||||
|
||||
})
|
||||
|
||||
it('detects shift after an earlier one was invalid', () => {
|
||||
const temps =
|
||||
[36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4,
|
||||
36.7, 36.7, 36.7, 36.7]
|
||||
.map(turnIntoCycleDayObject)
|
||||
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 10,
|
||||
temperature: { value: 36.7 }
|
||||
},
|
||||
|
||||
evaluationCompleteDay: {
|
||||
date: 13,
|
||||
temperature : { value: 36.7 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 1
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('2nd exception rule', () => {
|
||||
it('detects temperature shift with exception temp eql ltl', () => {
|
||||
const secondException =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55,
|
||||
36.8, 36.86, 36.6, 36.8]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(secondException)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 7,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
|
||||
evaluationCompleteDay: {
|
||||
date: 10,
|
||||
temperature : { value: 36.8 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 2
|
||||
})
|
||||
})
|
||||
|
||||
it('detects temperature shift with exception temp lower than ltl', () => {
|
||||
const secondException =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55,
|
||||
36.8, 36.86, 36.4, 36.8]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(secondException)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.6,
|
||||
firstHighMeasurementDay: {
|
||||
date: 7,
|
||||
temperature: { value: 36.8 }
|
||||
},
|
||||
|
||||
evaluationCompleteDay: {
|
||||
date: 10,
|
||||
temperature : { value: 36.8 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 2
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
it('detects missing temperature shift correctly', () => {
|
||||
const temps =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55,
|
||||
36.8, 36.86, 36.4, 36.77, 36.77]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects missing temperature shift when not enough high temps', () => {
|
||||
const temps =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.4]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('detects shift after an earlier one was invalid', () => {
|
||||
const temps =
|
||||
[36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.4,
|
||||
36.77, 36.9, 36.9, 36.86, 37.04]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getTemperatureStatus(temps)
|
||||
expect(status).to.eql({
|
||||
ltl: 36.85,
|
||||
firstHighMeasurementDay: {
|
||||
date: 11,
|
||||
temperature: { value: 36.9 }
|
||||
},
|
||||
|
||||
evaluationCompleteDay: {
|
||||
date: 14,
|
||||
temperature : { value: 37.04 }
|
||||
},
|
||||
detected: true,
|
||||
rule: 2
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user