Skip to content
Snippets Groups Projects
Commit de4d3955 authored by Julia Friesel's avatar Julia Friesel
Browse files

Add test for getAllMensesStart speed

parent 1aeaac85
No related branches found
No related tags found
No related merge requests found
import chai from 'chai'
import dirtyChai from 'dirty-chai'
import cycleModule from '../lib/cycle'
import { LocalDate } from 'js-joda'
const expect = chai.expect
chai.use(dirtyChai)
......@@ -663,4 +664,25 @@ describe('getAllMensesStart', () => {
expect(result.length).to.eql(0)
expect(result).to.eql([])
})
it('is not slow with 500 menses starts', () => {
const startDate = LocalDate.parse('2018-10-01')
const cycleDaysSortedByDate = Array(500)
.fill(null)
.map((_, i) => {
return {
date: startDate.minusMonths(i).toString(),
bleeding: { value: 2 }
}
})
const { getAllMensesStarts } = cycleModule({
cycleDaysSortedByDate,
bleedingDaysSortedByDate: cycleDaysSortedByDate
})
const start = Date.now()
const result = getAllMensesStarts()
const duration = Date.now() - start
expect(result.length).to.eql(500)
expect(duration).to.be.lessThan(100)
})
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment