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

generate_branch_name_spec.js « services « static_site_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7e437506a16068e14e1143752d5b4ce5e8d7cf49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { BRANCH_SUFFIX_COUNT } from '~/static_site_editor/constants';
import generateBranchName from '~/static_site_editor/services/generate_branch_name';

import { username, branch as targetBranch } from '../mock_data';

describe('generateBranchName', () => {
  const timestamp = 12345678901234;

  beforeEach(() => {
    jest.spyOn(Date, 'now').mockReturnValueOnce(timestamp);
  });

  it('generates a name that includes the username and target branch', () => {
    expect(generateBranchName(username, targetBranch)).toMatch(`${username}-${targetBranch}`);
  });

  it(`adds the first ${BRANCH_SUFFIX_COUNT} numbers of the current timestamp`, () => {
    expect(generateBranchName(username, targetBranch)).toMatch(
      timestamp.toString().substring(BRANCH_SUFFIX_COUNT),
    );
  });
});