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

utils_spec.js « command_palette « global_search « components « super_sidebar « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ebc52e2d910aea8b7dcd6690129bca9eeb1c61bd (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
import {
  commandMapper,
  linksReducer,
  fileMapper,
} from '~/super_sidebar/components/global_search/command_palette/utils';
import { COMMANDS, LINKS, TRANSFORMED_LINKS } from './mock_data';

describe('linksReducer', () => {
  it('should transform links', () => {
    expect(LINKS.reduce(linksReducer, [])).toEqual(TRANSFORMED_LINKS);
  });
});

describe('commandMapper', () => {
  it('should temporarily remove the `invite_members` item', () => {
    const initialCommandsLength = COMMANDS[0].items.length;
    expect(COMMANDS.map(commandMapper)[0].items).toHaveLength(initialCommandsLength - 1);
  });
});

describe('fileMapper', () => {
  it('should transform files', () => {
    const file = 'file';
    const projectBlobPath = 'project/blob/path';
    expect(fileMapper(projectBlobPath, file)).toEqual({
      icon: 'doc-code',
      text: file,
      href: `${projectBlobPath}/${file}`,
    });
  });
});