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

commit_icon_spec.js « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3acdfec5393280800573cb6258ccb039647d3739 (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
41
42
43
import getCommitIconMap from '~/ide/commit_icon';
import { commitItemIconMap } from '~/ide/constants';
import { decorateData } from '~/ide/stores/utils';

const createFile = (name = 'name', id = name, type = '', parent = null) =>
  decorateData({
    id,
    type,
    icon: 'icon',
    name,
    path: parent ? `${parent.path}/${name}` : name,
    parentPath: parent ? parent.path : '',
  });

describe('getCommitIconMap', () => {
  let entry;

  beforeEach(() => {
    entry = createFile('Entry item');
  });

  it('renders "deleted" icon for deleted entries', () => {
    entry.deleted = true;
    expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.deleted);
  });

  it('renders "addition" icon for temp entries', () => {
    entry.tempFile = true;
    expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.addition);
  });

  it('renders "modified" icon for newly-renamed entries', () => {
    entry.prevPath = 'foo/bar';
    entry.tempFile = false;
    expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
  });

  it('renders "modified" icon even for temp entries if they are newly-renamed', () => {
    entry.prevPath = 'foo/bar';
    entry.tempFile = true;
    expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
  });
});