Improving cervix:
* adding tempEvalEnd value to cervix tests * more comments in code for cervix sympto * better description in cervix temp tests * take out cervix.value
This commit is contained in:
+107
-34
@@ -5,87 +5,160 @@ const expect = chai.expect
|
||||
|
||||
function turnIntoCycleDayObject(value, fakeDate) {
|
||||
const hardAndClosed = {
|
||||
value: { opening: 0, firmness: 0 }
|
||||
opening: 0,
|
||||
firmness: 0
|
||||
}
|
||||
const hardAndOpen = {
|
||||
value: { opening: 1, firmness: 0 }
|
||||
opening: 1,
|
||||
firmness: 0
|
||||
}
|
||||
const softAndClosed = {
|
||||
value: { opening: 0, firmness: 1 }
|
||||
opening: 0,
|
||||
firmness: 1
|
||||
}
|
||||
const softAndOpen = {
|
||||
value: { opening: 1, firmness: 1 }
|
||||
opening: 1,
|
||||
firmness: 1
|
||||
}
|
||||
const cervixStates = [hardAndClosed, hardAndOpen, softAndClosed, softAndOpen]
|
||||
return {
|
||||
date: fakeDate,
|
||||
cervix: cervixStates[value],
|
||||
exclude: false
|
||||
cervix: {
|
||||
opening: cervixStates[value].opening,
|
||||
firmness: cervixStates[value].firmness,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('detects cervix shift', () => {
|
||||
it('when shift happens at day 15 with consistent following days', function () {
|
||||
const values = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3, 1, 3, 1, 0, 0, 0, 0]
|
||||
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)
|
||||
const status = getCervixStatus(values, 16)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 13,
|
||||
cervix: {value: { opening: 1, firmness: 0 }},
|
||||
exclude: false
|
||||
date: 10,
|
||||
cervix: {
|
||||
opening: 1,
|
||||
firmness: 1,
|
||||
exclude: false
|
||||
}
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 16,
|
||||
cervix: { value: { opening: 0, firmness: 0 }},
|
||||
exclude: false
|
||||
date: 13,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
it('at the very first day of cycle days even if later shift happens again', function () {
|
||||
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)
|
||||
const status = getCervixStatus(values, 5)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 0,
|
||||
cervix: { value: { opening: 0, firmness: 1 } },
|
||||
exclude: false
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 1,
|
||||
exclude: false
|
||||
},
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 3,
|
||||
cervix: { value: { opening: 0, firmness: 0 } },
|
||||
exclude: false
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
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: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 13,
|
||||
cervix: {
|
||||
opening: 1,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 16,
|
||||
cervix: {
|
||||
opening: 0,
|
||||
firmness: 0,
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('detects no cervix shift', () => {
|
||||
it('if there are less than 3 days closed and hard cervix', function () {
|
||||
const values = [0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 1, 1, 1, 0, 0, 2, 0]
|
||||
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)
|
||||
const status = getCervixStatus(values, 15)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if there are no cervix values', function () {
|
||||
const values = [].map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('when the cervix values are all the same', function () {
|
||||
const values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
it('if cycleDays have not enough cervix values to detect valid cervix shift', () => {
|
||||
const values = [2,0,0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
const status = getCervixStatus(values, 17)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
it('if no days of hard and closed cervix are tracked', function () {
|
||||
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)
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user