Commit 2bb36a0f authored by Brandon Labuschagne's avatar Brandon Labuschagne Committed by Martin Wortschack

MR Analytics - Fix throughput chart date range calculation

parent e492d82c
......@@ -25,7 +25,7 @@ export const computeMonthRangeData = (startDate, endDate, format = dateFormats.i
for (
let dateCursor = new Date(endDate);
dateCursor >= startDate;
dateCursor.setMonth(dateCursor.getMonth() - 1)
dateCursor.setMonth(dateCursor.getMonth(), 0)
) {
const monthIndex = dateCursor.getMonth();
const year = dateCursor.getFullYear();
......
......@@ -2,10 +2,13 @@ import * as utils from 'ee/analytics/merge_request_analytics/utils';
import { expectedMonthData } from './mock_data';
describe('computeMonthRangeData', () => {
it('returns the data as expected', () => {
const startDate = new Date('2020-05-17T00:00:00.000Z');
const endDate = new Date('2020-07-17T00:00:00.000Z');
const start = new Date('2020-05-17T00:00:00.000Z');
it.each`
startDate | endDate
${start} | ${new Date('2020-07-17T00:00:00.000Z')}
${start} | ${new Date('2020-07-31T00:00:00.000Z')}
`('returns the data as expected', ({ startDate, endDate }) => {
const monthData = utils.computeMonthRangeData(startDate, endDate);
expect(monthData).toStrictEqual(expectedMonthData);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment