summaryrefslogtreecommitdiff
path: root/spec/frontend/pipeline_new/utils/format_refs_spec.js
blob: 1fda6a8af830d690ccd6e14b41519bec3343c493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import formatRefs from '~/pipeline_new/utils/format_refs';
import { BRANCH_REF_TYPE, TAG_REF_TYPE } from '~/pipeline_new/constants';
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/master', shortName: 'master' },
      { 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' },
    ]);
  });
});