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);
},
);
});
});
|