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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { mount } from '@vue/test-utils';
2018-10-15 14:42:47 +05:30
import Vue from 'vue';
2021-01-03 14:25:43 +05:30
import Vuex from 'vuex';
2021-03-08 18:12:59 +05:30
import { keepAlive } from 'helpers/keep_alive_component_helper';
2018-10-15 14:42:47 +05:30
import IdeTree from '~/ide/components/ide_tree.vue';
2020-10-24 23:57:45 +05:30
import { createStore } from '~/ide/stores';
import { file } from '../helpers';
2018-10-15 14:42:47 +05:30
import { projectData } from '../mock_data';
2022-04-04 11:22:00 +05:30
Vue.use(Vuex);
2021-01-03 14:25:43 +05:30
describe('IdeTree', () => {
2020-10-24 23:57:45 +05:30
let store;
2021-01-03 14:25:43 +05:30
let wrapper;
2018-10-15 14:42:47 +05:30
beforeEach(() => {
2020-10-24 23:57:45 +05:30
store = createStore();
2018-10-15 14:42:47 +05:30
store.state.currentProjectId = 'abcproject';
2021-09-04 01:27:46 +05:30
store.state.currentBranchId = 'main';
2020-05-24 23:13:21 +05:30
store.state.projects.abcproject = { ...projectData };
2021-09-04 01:27:46 +05:30
Vue.set(store.state.trees, 'abcproject/main', {
2018-10-15 14:42:47 +05:30
tree: [file('fileName')],
loading: false,
});
2021-01-03 14:25:43 +05:30
wrapper = mount(keepAlive(IdeTree), {
store,
});
2018-10-15 14:42:47 +05:30
});
afterEach(() => {
2021-01-03 14:25:43 +05:30
wrapper.destroy();
2018-10-15 14:42:47 +05:30
});
it('renders list of files', () => {
2021-01-03 14:25:43 +05:30
expect(wrapper.text()).toContain('fileName');
});
describe('activated', () => {
let inititializeSpy;
beforeEach(async () => {
inititializeSpy = jest.spyOn(wrapper.find(IdeTree).vm, 'initialize');
store.state.viewer = 'diff';
await wrapper.vm.reactivate();
});
it('re initializes the component', () => {
expect(inititializeSpy).toHaveBeenCalled();
});
it('updates viewer to "editor" by default', () => {
expect(store.state.viewer).toBe('editor');
});
2018-10-15 14:42:47 +05:30
});
});