Commit f2e5eba7 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '243446-merge-request-analytics-fix-throughput-chart-date-range-calculator' into 'master'

MR Analytics - Fix throughput chart date range calculation

See merge request gitlab-org/gitlab!40847
parents 4c375307 2bb36a0f
...@@ -25,7 +25,7 @@ export const computeMonthRangeData = (startDate, endDate, format = dateFormats.i ...@@ -25,7 +25,7 @@ export const computeMonthRangeData = (startDate, endDate, format = dateFormats.i
for ( for (
let dateCursor = new Date(endDate); let dateCursor = new Date(endDate);
dateCursor >= startDate; dateCursor >= startDate;
dateCursor.setMonth(dateCursor.getMonth() - 1) dateCursor.setMonth(dateCursor.getMonth(), 0)
) { ) {
const monthIndex = dateCursor.getMonth(); const monthIndex = dateCursor.getMonth();
const year = dateCursor.getFullYear(); const year = dateCursor.getFullYear();
......
...@@ -2,10 +2,13 @@ import * as utils from 'ee/analytics/merge_request_analytics/utils'; ...@@ -2,10 +2,13 @@ import * as utils from 'ee/analytics/merge_request_analytics/utils';
import { expectedMonthData } from './mock_data'; import { expectedMonthData } from './mock_data';
describe('computeMonthRangeData', () => { describe('computeMonthRangeData', () => {
it('returns the data as expected', () => { const start = new Date('2020-05-17T00:00:00.000Z');
const startDate = new Date('2020-05-17T00:00:00.000Z');
const endDate = new Date('2020-07-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); const monthData = utils.computeMonthRangeData(startDate, endDate);
expect(monthData).toStrictEqual(expectedMonthData); 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