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 repoFileButtons from '~/ide/components/repo_file_buttons.vue';
|
|
|
|
import { file, resetStore } from '../helpers';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('RepoFileButtons', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const activeFile = file();
|
|
|
|
let vm;
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
function createComponent() {
|
|
|
|
const RepoFileButtons = Vue.extend(repoFileButtons);
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
activeFile.rawPath = 'test';
|
|
|
|
activeFile.blamePath = 'test';
|
|
|
|
activeFile.commitsPath = 'test';
|
|
|
|
activeFile.active = true;
|
|
|
|
store.state.openFiles.push(activeFile);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
return new RepoFileButtons({
|
|
|
|
store,
|
|
|
|
}).$mount();
|
|
|
|
}
|
2017-09-10 17:25:29 +05:30
|
|
|
|
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 Raw, Blame, History, Permalink and Preview toggle', (done) => {
|
|
|
|
vm = createComponent();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
vm.$nextTick(() => {
|
|
|
|
const raw = vm.$el.querySelector('.raw');
|
|
|
|
const blame = vm.$el.querySelector('.blame');
|
|
|
|
const history = vm.$el.querySelector('.history');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(raw.href).toMatch(`/${activeFile.rawPath}`);
|
|
|
|
expect(raw.textContent.trim()).toEqual('Raw');
|
|
|
|
expect(blame.href).toMatch(`/${activeFile.blamePath}`);
|
|
|
|
expect(blame.textContent.trim()).toEqual('Blame');
|
|
|
|
expect(history.href).toMatch(`/${activeFile.commitsPath}`);
|
|
|
|
expect(history.textContent.trim()).toEqual('History');
|
|
|
|
expect(vm.$el.querySelector('.permalink').textContent.trim()).toEqual('Permalink');
|
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
|
|
|
});
|
|
|
|
});
|