failing spec fixes
This commit is contained in:
parent
389c852d12
commit
10dcaea1c3
6 changed files with 42 additions and 47 deletions
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
entryName: '',
|
entryName: RepoStore.path !== '' ? `${RepoStore.path}/` : '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -30,6 +30,8 @@
|
||||||
const dirNames = this.entryName.split('/');
|
const dirNames = this.entryName.split('/');
|
||||||
|
|
||||||
dirNames.forEach((dirName) => {
|
dirNames.forEach((dirName) => {
|
||||||
|
if (dirName === '') return;
|
||||||
|
|
||||||
tree = RepoHelper.findOrCreateEntry('tree', tree, dirName).entry;
|
tree = RepoHelper.findOrCreateEntry('tree', tree, dirName).entry;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,35 +16,28 @@ const RepoEditor = {
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
if (!this.activeFile.tempFile) {
|
Service.getRaw(this.activeFile)
|
||||||
Service.getRaw(this.activeFile.raw_path)
|
.then((rawResponse) => {
|
||||||
.then((rawResponse) => {
|
Store.blobRaw = rawResponse.data;
|
||||||
Store.blobRaw = rawResponse.data;
|
Store.activeFile.plain = rawResponse.data;
|
||||||
Store.activeFile.plain = rawResponse.data;
|
|
||||||
|
|
||||||
this.createMonacoInstance();
|
const monacoInstance = Helper.monaco.editor.create(this.$el, {
|
||||||
})
|
model: null,
|
||||||
.catch(Helper.loadingError);
|
readOnly: false,
|
||||||
} else {
|
contextmenu: true,
|
||||||
this.createMonacoInstance();
|
scrollBeyondLastLine: false,
|
||||||
}
|
});
|
||||||
|
|
||||||
|
Helper.monacoInstance = monacoInstance;
|
||||||
|
|
||||||
|
this.addMonacoEvents();
|
||||||
|
|
||||||
|
this.setupEditor();
|
||||||
|
})
|
||||||
|
.catch(Helper.loadingError);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
createMonacoInstance() {
|
|
||||||
const monacoInstance = Helper.monaco.editor.create(this.$el, {
|
|
||||||
model: null,
|
|
||||||
readOnly: false,
|
|
||||||
contextmenu: true,
|
|
||||||
scrollBeyondLastLine: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
Helper.monacoInstance = monacoInstance;
|
|
||||||
|
|
||||||
this.addMonacoEvents();
|
|
||||||
|
|
||||||
this.setupEditor();
|
|
||||||
},
|
|
||||||
setupEditor() {
|
setupEditor() {
|
||||||
this.showHide();
|
this.showHide();
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ const RepoHelper = {
|
||||||
RepoHelper.setBinaryDataAsBase64(data);
|
RepoHelper.setBinaryDataAsBase64(data);
|
||||||
Store.setViewToPreview();
|
Store.setViewToPreview();
|
||||||
} else if (!Store.isPreviewView() && !data.render_error) {
|
} else if (!Store.isPreviewView() && !data.render_error) {
|
||||||
Service.getRaw(data.raw_path)
|
Service.getRaw(data)
|
||||||
.then((rawResponse) => {
|
.then((rawResponse) => {
|
||||||
Store.blobRaw = rawResponse.data;
|
Store.blobRaw = rawResponse.data;
|
||||||
data.plain = rawResponse.data;
|
data.plain = rawResponse.data;
|
||||||
|
|
|
@ -12,8 +12,14 @@ const RepoService = {
|
||||||
},
|
},
|
||||||
richExtensionRegExp: /md/,
|
richExtensionRegExp: /md/,
|
||||||
|
|
||||||
getRaw(url) {
|
getRaw(file) {
|
||||||
return axios.get(url, {
|
if (file.tempFile) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.get(file.raw_path, {
|
||||||
// Stop Axios from parsing a JSON file into a JS object
|
// Stop Axios from parsing a JSON file into a JS object
|
||||||
transformResponse: [res => res],
|
transformResponse: [res => res],
|
||||||
});
|
});
|
||||||
|
|
|
@ -77,7 +77,7 @@ const RepoStore = {
|
||||||
} else if (file.newContent || file.plain) {
|
} else if (file.newContent || file.plain) {
|
||||||
RepoStore.blobRaw = file.newContent || file.plain;
|
RepoStore.blobRaw = file.newContent || file.plain;
|
||||||
} else if (!file.tempFile) {
|
} else if (!file.tempFile) {
|
||||||
Service.getRaw(file.raw_path)
|
Service.getRaw(file)
|
||||||
.then((rawResponse) => {
|
.then((rawResponse) => {
|
||||||
RepoStore.blobRaw = rawResponse.data;
|
RepoStore.blobRaw = rawResponse.data;
|
||||||
Helper.findOpenedFileFromActive().plain = rawResponse.data;
|
Helper.findOpenedFileFromActive().plain = rawResponse.data;
|
||||||
|
|
|
@ -2,7 +2,16 @@ import Vue from 'vue';
|
||||||
import repoFileButtons from '~/repo/components/repo_file_buttons.vue';
|
import repoFileButtons from '~/repo/components/repo_file_buttons.vue';
|
||||||
import RepoStore from '~/repo/stores/repo_store';
|
import RepoStore from '~/repo/stores/repo_store';
|
||||||
|
|
||||||
describe('RepoFileButtons', () => {
|
fdescribe('RepoFileButtons', () => {
|
||||||
|
const activeFile = {
|
||||||
|
extension: 'md',
|
||||||
|
url: 'url',
|
||||||
|
raw_path: 'raw_path',
|
||||||
|
blame_path: 'blame_path',
|
||||||
|
commits_path: 'commits_path',
|
||||||
|
permalink: 'permalink',
|
||||||
|
};
|
||||||
|
|
||||||
function createComponent() {
|
function createComponent() {
|
||||||
const RepoFileButtons = Vue.extend(repoFileButtons);
|
const RepoFileButtons = Vue.extend(repoFileButtons);
|
||||||
|
|
||||||
|
@ -14,14 +23,6 @@ describe('RepoFileButtons', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders Raw, Blame, History, Permalink and Preview toggle', () => {
|
it('renders Raw, Blame, History, Permalink and Preview toggle', () => {
|
||||||
const activeFile = {
|
|
||||||
extension: 'md',
|
|
||||||
url: 'url',
|
|
||||||
raw_path: 'raw_path',
|
|
||||||
blame_path: 'blame_path',
|
|
||||||
commits_path: 'commits_path',
|
|
||||||
permalink: 'permalink',
|
|
||||||
};
|
|
||||||
const activeFileLabel = 'activeFileLabel';
|
const activeFileLabel = 'activeFileLabel';
|
||||||
RepoStore.openedFiles = new Array(1);
|
RepoStore.openedFiles = new Array(1);
|
||||||
RepoStore.activeFile = activeFile;
|
RepoStore.activeFile = activeFile;
|
||||||
|
@ -46,10 +47,6 @@ describe('RepoFileButtons', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers rawPreviewToggle on preview click', () => {
|
it('triggers rawPreviewToggle on preview click', () => {
|
||||||
const activeFile = {
|
|
||||||
extension: 'md',
|
|
||||||
url: 'url',
|
|
||||||
};
|
|
||||||
RepoStore.openedFiles = new Array(1);
|
RepoStore.openedFiles = new Array(1);
|
||||||
RepoStore.activeFile = activeFile;
|
RepoStore.activeFile = activeFile;
|
||||||
RepoStore.editMode = true;
|
RepoStore.editMode = true;
|
||||||
|
@ -65,10 +62,7 @@ describe('RepoFileButtons', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render preview toggle if not canPreview', () => {
|
it('does not render preview toggle if not canPreview', () => {
|
||||||
const activeFile = {
|
activeFile.extension = 'js';
|
||||||
extension: 'abcd',
|
|
||||||
url: 'url',
|
|
||||||
};
|
|
||||||
RepoStore.openedFiles = new Array(1);
|
RepoStore.openedFiles = new Array(1);
|
||||||
RepoStore.activeFile = activeFile;
|
RepoStore.activeFile = activeFile;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue