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

tick_formats_spec.js « utils « lib « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 283989b4fc873dfe46cb4fc418fb317055e08cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { dateTickFormat, initDateFormats } from '~/lib/utils/tick_formats';

import { setLanguage } from '../../helpers/locale_helper';

describe('tick formats', () => {
  describe('dateTickFormat', () => {
    beforeAll(() => {
      setLanguage('de');
      initDateFormats();
    });

    afterAll(() => {
      setLanguage(null);
    });

    it('returns year for first of January', () => {
      const tick = dateTickFormat(new Date('2001-01-01'));

      expect(tick).toBe('2001');
    });

    it('returns month for first of February', () => {
      const tick = dateTickFormat(new Date('2001-02-01'));

      expect(tick).toBe('Februar');
    });

    it('returns day and month for second of February', () => {
      const tick = dateTickFormat(new Date('2001-02-02'));

      expect(tick).toBe('2. Feb.');
    });

    it('ignores time', () => {
      const tick = dateTickFormat(new Date('2001-02-02 12:34:56'));

      expect(tick).toBe('2. Feb.');
    });
  });
});