Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils_spec.js « contributors « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2b9154329be4ff504f422e340d72fe0dc4dc77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as utils from '~/contributors/utils';

describe('Contributors Util Functions', () => {
  describe('xAxisLabelFormatter', () => {
    it('should return year if the date is in January', () => {
      expect(utils.xAxisLabelFormatter(new Date('01-12-2019'))).toEqual('2019');
    });

    it('should return month name otherwise', () => {
      expect(utils.xAxisLabelFormatter(new Date('12-02-2019'))).toEqual('Dec');
      expect(utils.xAxisLabelFormatter(new Date('07-12-2019'))).toEqual('Jul');
    });
  });

  describe('dateFormatter', () => {
    it('should format provided date to YYYY-MM-DD format', () => {
      expect(utils.dateFormatter(new Date('December 17, 1995 03:24:00'))).toEqual('1995-12-17');
      expect(utils.dateFormatter(new Date(1565308800000))).toEqual('2019-08-09');
    });
  });
});