Fixing cervix unit tests
This commit is contained in:
+17
-39
@@ -5,53 +5,45 @@ const expect = chai.expect
|
||||
|
||||
function turnIntoCycleDayObject(value, fakeDate) {
|
||||
const hardAndClosed = {
|
||||
isHard: true,
|
||||
isClosed: true
|
||||
value: { opening: 0, firmness: 0 }
|
||||
}
|
||||
const hardAndOpen = {
|
||||
isHard: true,
|
||||
isClosed: false
|
||||
value: { opening: 1, firmness: 0 }
|
||||
}
|
||||
const softAndClosed = {
|
||||
isHard: false,
|
||||
isClosed: true
|
||||
value: { opening: 0, firmness: 1 }
|
||||
}
|
||||
const softAndOpen = {
|
||||
isHard: false,
|
||||
isClosed: false
|
||||
value: { opening: 1, firmness: 1 }
|
||||
}
|
||||
const cervixStates = [hardAndClosed, hardAndOpen, softAndClosed, softAndOpen]
|
||||
return {
|
||||
cervix : cervixStates[value],
|
||||
date: fakeDate
|
||||
date: fakeDate,
|
||||
cervix: cervixStates[value],
|
||||
exclude: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('sympto', () => {
|
||||
describe('detects cervix shift', () => {
|
||||
it('when an ideal cycle happens', function () {
|
||||
const values = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 0, 0, 0, 0]
|
||||
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]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
expect(status).to.eql({
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 13,
|
||||
cervix: {
|
||||
isHard: true,
|
||||
isClosed: false
|
||||
}
|
||||
cervix: {value: { opening: 1, firmness: 0 }},
|
||||
exclude: false
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 16,
|
||||
cervix: {
|
||||
isHard: true,
|
||||
isClosed: true
|
||||
}
|
||||
cervix: { value: { opening: 0, firmness: 0 }},
|
||||
exclude: false
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('at the very first day of cycle days even if later shift happens again', function () {
|
||||
const values = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
.map(turnIntoCycleDayObject)
|
||||
@@ -60,17 +52,13 @@ describe('sympto', () => {
|
||||
detected: true,
|
||||
cervixPeakBeforeShift: {
|
||||
date: 0,
|
||||
cervix: {
|
||||
isHard: false,
|
||||
isClosed: true
|
||||
}
|
||||
cervix: { value: { opening: 0, firmness: 1 } },
|
||||
exclude: false
|
||||
},
|
||||
evaluationCompleteDay: {
|
||||
date: 3,
|
||||
cervix: {
|
||||
isHard: true,
|
||||
isClosed: true
|
||||
}
|
||||
cervix: { value: { opening: 0, firmness: 0 } },
|
||||
exclude: false
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -83,32 +71,22 @@ describe('sympto', () => {
|
||||
const status = getCervixStatus(values)
|
||||
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]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('if no days of hard and closed cervix are tracked', function () {
|
||||
const values = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
|
||||
it('if days of hard and closed cervix are fewer than 3', function () {
|
||||
const values = [1, 3, 2, 1, 0, 2, 1, 3, 2, 0, 0, 2, 1, 3, 2, 1]
|
||||
.map(turnIntoCycleDayObject)
|
||||
const status = getCervixStatus(values)
|
||||
expect(status).to.eql({ detected: false })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user