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

getters_spec.js « editor « modules « stores « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 55e1e31f66f037d5ecf67a83e0767c9c7aa0e16e (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 { createDefaultFileEditor } from '~/ide/stores/modules/editor/utils';
import * as getters from '~/ide/stores/modules/editor/getters';

const TEST_PATH = 'test/path.md';
const TEST_FILE_EDITOR = {
  ...createDefaultFileEditor(),
  editorRow: 7,
  editorColumn: 8,
  fileLanguage: 'markdown',
};

describe('~/ide/stores/modules/editor/getters', () => {
  describe('activeFileEditor', () => {
    it.each`
      activeFile             | fileEditors                                                            | expected
      ${null}                | ${{}}                                                                  | ${null}
      ${{}}                  | ${{}}                                                                  | ${createDefaultFileEditor()}
      ${{ path: TEST_PATH }} | ${{}}                                                                  | ${createDefaultFileEditor()}
      ${{ path: TEST_PATH }} | ${{ bogus: createDefaultFileEditor(), [TEST_PATH]: TEST_FILE_EDITOR }} | ${TEST_FILE_EDITOR}
    `(
      'with activeFile=$activeFile and fileEditors=$fileEditors',
      ({ activeFile, fileEditors, expected }) => {
        const rootGetters = { activeFile };
        const state = { fileEditors };
        const result = getters.activeFileEditor(state, {}, {}, rootGetters);

        expect(result).toEqual(expected);
      },
    );
  });
});