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
|
|
|
});
|
|
|
|
|
|
|
|
it('renders list of files', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(wrapper.text()).toContain('fileName');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('activated', () => {
|
|
|
|
let inititializeSpy;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
2022-08-27 11:52:29 +05:30
|
|
|
inititializeSpy = jest.spyOn(wrapper.findComponent(IdeTree).vm, 'initialize');
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
|
|
});
|
|
|
|
});
|