Respect maxcyclelength in getCycleForStartDay
This commit is contained in:
+41
-2
@@ -71,8 +71,6 @@ describe('getCycleDayNumber', () => {
|
||||
const result = getCycleDayNumber(targetDate)
|
||||
expect(result).to.be.null()
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
describe('getPreviousCycle', () => {
|
||||
@@ -433,6 +431,47 @@ describe('getCycleForDay', () => {
|
||||
expect(result).to.eql(null)
|
||||
})
|
||||
|
||||
it('returns null if the cycle is longer than the max', () => {
|
||||
const { getCycleForDay } = cycleModule({
|
||||
cycleDaysSortedByDate,
|
||||
cycleStartsSortedByDate: cycleDaysSortedByDate.filter(d => {
|
||||
return cycleStarts.includes(d.date)
|
||||
}),
|
||||
maxCycleLength: 3
|
||||
})
|
||||
const result = getCycleForDay('2018-04-04')
|
||||
expect(result).to.eql(null)
|
||||
})
|
||||
|
||||
it('returns the cycle if the cycle is shorter or equal max', () => {
|
||||
const { getCycleForDay } = cycleModule({
|
||||
cycleDaysSortedByDate,
|
||||
cycleStartsSortedByDate: cycleDaysSortedByDate.filter(d => {
|
||||
return cycleStarts.includes(d.date)
|
||||
}),
|
||||
maxCycleLength: 4
|
||||
})
|
||||
const result = getCycleForDay('2018-04-04')
|
||||
expect(result).to.eql([
|
||||
{
|
||||
date: '2018-04-05',
|
||||
mucus: { value: 2 }
|
||||
},
|
||||
{
|
||||
date: '2018-04-04',
|
||||
mucus: { value: 2 }
|
||||
},
|
||||
{
|
||||
date: '2018-04-03',
|
||||
mucus: { value: 2 }
|
||||
},
|
||||
{
|
||||
date: '2018-04-02',
|
||||
bleeding: { value: 2 }
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('gets cycle for day', () => {
|
||||
const result = getCycleForDay('2018-04-04')
|
||||
expect(result.length).to.eql(4)
|
||||
|
||||
Reference in New Issue
Block a user