Adds test and fixes getCycleByStartDate method of cycle module

This commit is contained in:
Sofiya Tepikin
2020-03-05 19:31:52 +01:00
parent e901cae0f5
commit 9e34c1b8b4
2 changed files with 98 additions and 24 deletions
+43
View File
@@ -0,0 +1,43 @@
import chai from 'chai'
import dirtyChai from 'dirty-chai'
import cycleModule from '../lib/cycle'
const { expect } = chai
chai.use(dirtyChai)
const cycleStartDay = { date: '2018-05-03' }
const cycle = [
{ date: '2018-05-05' },
{ date: '2018-05-04' },
cycleStartDay,
]
const cycleDaysSortedByDate = [
{ date: '2018-07-05' },
{ date: '2018-06-05' },
...cycle,
{ date: '2018-04-05' },
{ date: '2018-04-04' },
{ date: '2018-04-03' },
{ date: '2018-04-02' },
]
const cycleStartsSortedByDate = [
{ date: '2018-07-05' },
{ date: '2018-06-05' },
{ date: '2018-05-03' },
{ date: '2018-04-02' },
]
describe('getCycleByStartDay', () => {
it('gets cycle by cycle start day', () => {
const { getCycleByStartDay } = cycleModule({
cycleDaysSortedByDate,
cycleStartsSortedByDate,
})
expect(getCycleByStartDay(cycleStartDay)).to.eql(cycle)
})
})