debian-mirror-gitlab/spec/frontend/ide/components/ide_status_list_spec.js

94 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-09-04 21:01:54 +05:30
import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils';
2020-07-28 23:09:34 +05:30
import { GlLink } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import IdeStatusList from '~/ide/components/ide_status_list.vue';
2020-06-23 00:09:42 +05:30
import TerminalSyncStatusSafe from '~/ide/components/terminal_sync/terminal_sync_status_safe.vue';
2019-09-04 21:01:54 +05:30
const TEST_FILE = {
name: 'lorem.md',
editorRow: 3,
editorColumn: 23,
fileLanguage: 'markdown',
2020-06-23 00:09:42 +05:30
content: 'abc\nndef',
2020-07-28 23:09:34 +05:30
permalink: '/lorem.md',
2019-09-04 21:01:54 +05:30
};
const localVue = createLocalVue();
localVue.use(Vuex);
describe('ide/components/ide_status_list', () => {
let activeFile;
let store;
let wrapper;
2020-07-28 23:09:34 +05:30
const findLink = () => wrapper.find(GlLink);
2019-09-04 21:01:54 +05:30
const createComponent = (options = {}) => {
store = new Vuex.Store({
getters: {
activeFile: () => activeFile,
},
});
2020-03-13 15:44:24 +05:30
wrapper = shallowMount(IdeStatusList, {
2019-09-04 21:01:54 +05:30
localVue,
store,
...options,
});
};
beforeEach(() => {
activeFile = TEST_FILE;
});
afterEach(() => {
wrapper.destroy();
store = null;
wrapper = null;
});
const getEditorPosition = file => `${file.editorRow}:${file.editorColumn}`;
describe('with regular file', () => {
beforeEach(() => {
createComponent();
});
2020-07-28 23:09:34 +05:30
it('shows a link to the file that contains the file name', () => {
expect(findLink().attributes('href')).toBe(TEST_FILE.permalink);
expect(findLink().text()).toBe(TEST_FILE.name);
2019-09-04 21:01:54 +05:30
});
it('shows file eol', () => {
2020-06-23 00:09:42 +05:30
expect(wrapper.text()).not.toContain('CRLF');
expect(wrapper.text()).toContain('LF');
2019-09-04 21:01:54 +05:30
});
it('shows file editor position', () => {
expect(wrapper.text()).toContain(getEditorPosition(TEST_FILE));
});
it('shows file language', () => {
expect(wrapper.text()).toContain(TEST_FILE.fileLanguage);
});
});
describe('with binary file', () => {
beforeEach(() => {
2020-11-24 15:15:51 +05:30
activeFile.name = 'abc.dat';
activeFile.content = '🐱'; // non-ascii binary content
2019-09-04 21:01:54 +05:30
createComponent();
});
it('does not show file editor position', () => {
expect(wrapper.text()).not.toContain(getEditorPosition(TEST_FILE));
});
});
2020-06-23 00:09:42 +05:30
it('renders terminal sync status', () => {
createComponent();
2019-09-04 21:01:54 +05:30
2020-06-23 00:09:42 +05:30
expect(wrapper.find(TerminalSyncStatusSafe).exists()).toBe(true);
2019-09-04 21:01:54 +05:30
});
});