2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import store from '~/ide/stores';
|
|
|
|
import repoLoadingFile from '~/ide/components/repo_loading_file.vue';
|
|
|
|
import { resetStore } from '../helpers';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('RepoLoadingFile', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
let vm;
|
|
|
|
|
|
|
|
function createComponent() {
|
2017-09-10 17:25:29 +05:30
|
|
|
const RepoLoadingFile = Vue.extend(repoLoadingFile);
|
|
|
|
|
|
|
|
return new RepoLoadingFile({
|
2018-03-17 18:26:18 +05:30
|
|
|
store,
|
2017-09-10 17:25:29 +05:30
|
|
|
}).$mount();
|
|
|
|
}
|
|
|
|
|
|
|
|
function assertLines(lines) {
|
|
|
|
lines.forEach((line, n) => {
|
|
|
|
const index = n + 1;
|
|
|
|
expect(line.classList.contains(`skeleton-line-${index}`)).toBeTruthy();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function assertColumns(columns) {
|
|
|
|
columns.forEach((column) => {
|
|
|
|
const container = column.querySelector('.animation-container');
|
|
|
|
const lines = [...container.querySelectorAll(':scope > div')];
|
|
|
|
|
|
|
|
expect(container).toBeTruthy();
|
|
|
|
expect(lines.length).toEqual(6);
|
|
|
|
assertLines(lines);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
resetStore(vm.$store);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('renders 3 columns of animated LoC', () => {
|
|
|
|
vm = createComponent();
|
2017-09-10 17:25:29 +05:30
|
|
|
const columns = [...vm.$el.querySelectorAll('td')];
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(columns.length).toEqual(3);
|
2017-09-10 17:25:29 +05:30
|
|
|
assertColumns(columns);
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('renders 1 column of animated LoC if isMini', (done) => {
|
|
|
|
vm = createComponent();
|
|
|
|
vm.$store.state.leftPanelCollapsed = true;
|
|
|
|
vm.$store.state.openFiles.push('test');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
vm.$nextTick(() => {
|
|
|
|
const columns = [...vm.$el.querySelectorAll('td')];
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(columns.length).toEqual(1);
|
|
|
|
assertColumns(columns);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
done();
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
});
|