summaryrefslogtreecommitdiff
path: root/spec/frontend/pipeline_new/utils/format_refs_spec.js
blob: 71190f55c166e9f54ca08df8c43ea50ed61e22e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { BRANCH_REF_TYPE, TAG_REF_TYPE } from '~/pipeline_new/constants';
import formatRefs from '~/pipeline_new/utils/format_refs';
import { mockBranchRefs, mockTagRefs } from '../mock_data';

describe('Format refs util', () => {
  it('formats branch ref correctly', () => {
    expect(formatRefs(mockBranchRefs, BRANCH_REF_TYPE)).toEqual([
      { fullName: 'refs/heads/main', shortName: 'main' },
      { fullName: 'refs/heads/dev', shortName: 'dev' },
      { fullName: 'refs/heads/release', shortName: 'release' },
    ]);
  });

  it('formats tag ref correctly', () => {
    expect(formatRefs(mockTagRefs, TAG_REF_TYPE)).toEqual([
      { fullName: 'refs/tags/1.0.0', shortName: '1.0.0' },
      { fullName: 'refs/tags/1.1.0', shortName: '1.1.0' },
      { fullName: 'refs/tags/1.2.0', shortName: '1.2.0' },
    ]);
  });
});