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

title_spec.js « utils « repository « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1213c13be8ab35807f81c0399ac4c80e7b3af7e (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
import { setTitle, updateRefPortionOfTitle } from '~/repository/utils/title';

describe('setTitle', () => {
  it.each`
    path                        | title
    ${'/'}                      | ${'Files'}
    ${'app'}                    | ${'app'}
    ${'app/assets'}             | ${'app/assets'}
    ${'app/assets/javascripts'} | ${'app/assets/javascripts'}
  `('sets document title as $title for $path', ({ path, title }) => {
    setTitle(path, 'master', 'GitLab Org / GitLab');

    expect(document.title).toEqual(`${title} · master · GitLab Org / GitLab · GitLab`);
  });
});

describe('updateRefPortionOfTitle', () => {
  const sha = 'abc';
  const testCases = [
    [
      'updates the title with the SHA',
      { title: 'part 1 · part 2 · part 3' },
      'part 1 · abc · part 3',
    ],
    ["makes no change if there's no title", { foo: null }, undefined],
    [
      "makes no change if the title doesn't split predictably",
      { title: 'part 1 - part 2 - part 3' },
      'part 1 - part 2 - part 3',
    ],
  ];

  it.each(testCases)('%s', (desc, doc, title) => {
    updateRefPortionOfTitle(sha, doc);

    expect(doc.title).toEqual(title);
  });
});