Combine temp and mucus evaluation

This commit is contained in:
Julia Friesel
2018-07-05 13:53:06 +02:00
parent f1f9c7773a
commit 836bea778c
5 changed files with 113 additions and 16 deletions
+77
View File
@@ -0,0 +1,77 @@
import chai from 'chai'
import getSensiplanStatus from '../../lib/sympto'
const expect = chai.expect
function convertToSymptoFormat(val, i) {
return {
date: i,
temperature: val.temperature ? { value: val.temperature } : null,
mucus: val.mucus ? { value: val.mucus } : null
}
}
describe('sympto', () => {
describe('evaluating mucus and temperature shift together', () => {
it('reports fertile when mucus reaches best quality again within temperature evaluation phase', function () {
const values = [
{ temperature: 36.6 },
{ temperature: 36.65 },
{ temperature: 36.5 },
{ temperature: 36.6 },
{ temperature: 36.55 },
{ temperature: 36.7, mucus: 0 },
{ temperature: 36.75, mucus: 0 },
{ temperature: 36.45, mucus: 1 },
{ temperature: 36.5, mucus: 4 },
{ temperature: 36.4, mucus: 2 },
{ temperature: 36.5, mucus: 3 },
{ temperature: 36.55, mucus: 3 },
{ temperature: 36.45, mucus: 3 },
{ temperature: 36.5, mucus: 4 },
{ temperature: 36.55, mucus: 4 },
{ temperature: 36.7, mucus: 3 },
{ temperature: 36.65, mucus: 3 },
{ temperature: 36.75, mucus: 4 },
{ temperature: 36.8, mucus: 1 },
{ temperature: 36.85, mucus: 2 },
{ temperature: 36.8, mucus: 2 },
{ temperature: 36.9, mucus: 2 },
{ temperature: 36.9, mucus: 1 },
{ temperature: 36.85, mucus: 1 },
{ temperature: 36.9, mucus: 1 },
{ temperature: 36.8, mucus: 1 },
{ temperature: 36.9, mucus: 1 }
]
const temperatures = values.map(convertToSymptoFormat)
const status = getSensiplanStatus(temperatures)
expect(status).to.eql({
assumeFertility: false,
temperatureShift: {
detected: true,
ltl: 36.55,
rule: 0,
firstHighMeasurementDay: {
date: 15,
temperature: { value: 36.7 },
mucus: { value: 3 }
},
evaluationCompleteDay: {
date: 17,
temperature: { value: 36.75 },
mucus: { value: 4 }
}
},
mucusShift: {
detected: true,
mucusPeak: {
date: 17,
mucus: { value: 4 },
temperature: { value: 36.75 }
}
}
})
})
})
})
+3 -3
View File
@@ -16,7 +16,7 @@ describe('sympto', () => {
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)
const status = getMucusStatus(values, 30)
expect(status).to.eql({
detected: true,
mucusPeak: {
@@ -29,7 +29,7 @@ describe('sympto', () => {
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)
const status = getMucusStatus(values, 30)
expect(status).to.eql({ detected: false })
})
@@ -41,7 +41,7 @@ describe('sympto', () => {
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)
const status = getMucusStatus(values, 30)
expect(status).to.eql({ detected: false })
})
})