updated specs
This commit is contained in:
parent
bfdeee1de9
commit
bead083c58
12 changed files with 40 additions and 30 deletions
|
@ -44,7 +44,7 @@ export default {
|
|||
this.updateViewer(viewer);
|
||||
|
||||
if (this.activeFile.pending) {
|
||||
this.removePendingTab(this.activeFile).then(() => {
|
||||
return this.removePendingTab(this.activeFile).then(() => {
|
||||
router.push(`/project${this.activeFile.url}`);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ export default class Model {
|
|||
|
||||
onChange(cb) {
|
||||
this.events.set(
|
||||
this.key,
|
||||
this.path,
|
||||
this.disposable.add(this.model.onDidChangeContent(e => cb(this, e))),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ export default class DirtyDiffController {
|
|||
|
||||
computeDiff(model) {
|
||||
this.dirtyDiffWorker.postMessage({
|
||||
key: model.path,
|
||||
path: model.path,
|
||||
originalContent: model.getOriginalModel().getValue(),
|
||||
newContent: model.getModel().getValue(),
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ export default class DirtyDiffController {
|
|||
|
||||
decorate({ data }) {
|
||||
const decorations = data.changes.map(change => getDecorator(change));
|
||||
const model = this.modelManager.getModel(data.key);
|
||||
const model = this.modelManager.getModel(data.path);
|
||||
this.decorationsController.addDecorations(model, 'dirtyDiff', decorations);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ self.addEventListener('message', e => {
|
|||
const data = e.data;
|
||||
|
||||
self.postMessage({
|
||||
key: data.key,
|
||||
path: data.path,
|
||||
changes: computeDiff(data.originalContent, data.newContent),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ export const discardAllChanges = ({ state, commit, dispatch }) => {
|
|||
};
|
||||
|
||||
export const closeAllFiles = ({ state, dispatch }) => {
|
||||
state.openFiles.forEach(file => dispatch('closeFile', file.path));
|
||||
state.openFiles.forEach(file => dispatch('closeFile', file));
|
||||
};
|
||||
|
||||
export const setPanelCollapsedStatus = ({ commit }, { side, collapsed }) => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import Vue from 'vue';
|
||||
import listItem from '~/ide/components/commit_sidebar/list_item.vue';
|
||||
import router from '~/ide/ide_router';
|
||||
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
||||
import store from '~/ide/stores';
|
||||
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
||||
import { file } from '../../helpers';
|
||||
|
||||
describe('Multi-file editor commit sidebar list item', () => {
|
||||
|
@ -13,9 +14,9 @@ describe('Multi-file editor commit sidebar list item', () => {
|
|||
|
||||
f = file('test-file');
|
||||
|
||||
vm = mountComponent(Component, {
|
||||
vm = createComponentWithStore(Component, store, {
|
||||
file: f,
|
||||
});
|
||||
}).$mount();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -36,20 +37,24 @@ describe('Multi-file editor commit sidebar list item', () => {
|
|||
expect(vm.discardFileChanges).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('opens a closed file in the editor when clicking the file path', () => {
|
||||
it('opens a closed file in the editor when clicking the file path', done => {
|
||||
spyOn(vm, 'openFileInEditor').and.callThrough();
|
||||
spyOn(vm, 'updateViewer');
|
||||
spyOn(vm, 'updateViewer').and.callThrough();
|
||||
spyOn(router, 'push');
|
||||
|
||||
vm.$el.querySelector('.multi-file-commit-list-path').click();
|
||||
|
||||
expect(vm.openFileInEditor).toHaveBeenCalled();
|
||||
expect(router.push).toHaveBeenCalled();
|
||||
setTimeout(() => {
|
||||
expect(vm.openFileInEditor).toHaveBeenCalled();
|
||||
expect(router.push).toHaveBeenCalled();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('calls updateViewer with diff when clicking file', () => {
|
||||
spyOn(vm, 'openFileInEditor').and.callThrough();
|
||||
spyOn(vm, 'updateViewer');
|
||||
spyOn(vm, 'updateViewer').and.callThrough();
|
||||
spyOn(router, 'push');
|
||||
|
||||
vm.$el.querySelector('.multi-file-commit-list-path').click();
|
||||
|
|
|
@ -59,7 +59,7 @@ describe('RepoTab', () => {
|
|||
|
||||
vm.$el.querySelector('.multi-file-tab-close').click();
|
||||
|
||||
expect(vm.closeFile).toHaveBeenCalledWith(vm.tab.path);
|
||||
expect(vm.closeFile).toHaveBeenCalledWith(vm.tab);
|
||||
});
|
||||
|
||||
it('changes icon on hover', done => {
|
||||
|
|
|
@ -17,6 +17,7 @@ describe('RepoTabs', () => {
|
|||
files: openedFiles,
|
||||
viewer: 'editor',
|
||||
hasChanges: false,
|
||||
activeFile: file('activeFile'),
|
||||
});
|
||||
openedFiles[0].active = true;
|
||||
|
||||
|
@ -56,6 +57,7 @@ describe('RepoTabs', () => {
|
|||
files: [],
|
||||
viewer: 'editor',
|
||||
hasChanges: false,
|
||||
activeFile: file('activeFile'),
|
||||
},
|
||||
'#test-app',
|
||||
);
|
||||
|
|
|
@ -27,9 +27,10 @@ describe('Multi-file editor library model manager', () => {
|
|||
});
|
||||
|
||||
it('caches model by file path', () => {
|
||||
instance.addModel(file('path-name'));
|
||||
const f = file('path-name');
|
||||
instance.addModel(f);
|
||||
|
||||
expect(instance.models.keys().next().value).toBe('path-name');
|
||||
expect(instance.models.keys().next().value).toBe(f.key);
|
||||
});
|
||||
|
||||
it('adds model into disposable', () => {
|
||||
|
@ -56,7 +57,7 @@ describe('Multi-file editor library model manager', () => {
|
|||
instance.addModel(f);
|
||||
|
||||
expect(eventHub.$on).toHaveBeenCalledWith(
|
||||
`editor.update.model.dispose.${f.path}`,
|
||||
`editor.update.model.dispose.${f.key}`,
|
||||
jasmine.anything(),
|
||||
);
|
||||
});
|
||||
|
@ -68,9 +69,11 @@ describe('Multi-file editor library model manager', () => {
|
|||
});
|
||||
|
||||
it('returns true when model exists', () => {
|
||||
instance.addModel(file('path-name'));
|
||||
const f = file('path-name');
|
||||
|
||||
expect(instance.hasCachedModel('path-name')).toBeTruthy();
|
||||
instance.addModel(f);
|
||||
|
||||
expect(instance.hasCachedModel(f.key)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -103,7 +106,7 @@ describe('Multi-file editor library model manager', () => {
|
|||
instance.removeCachedModel(f);
|
||||
|
||||
expect(eventHub.$off).toHaveBeenCalledWith(
|
||||
`editor.update.model.dispose.${f.path}`,
|
||||
`editor.update.model.dispose.${f.key}`,
|
||||
jasmine.anything(),
|
||||
);
|
||||
});
|
||||
|
|
|
@ -28,14 +28,14 @@ describe('Multi-file editor library model', () => {
|
|||
|
||||
it('adds eventHub listener', () => {
|
||||
expect(eventHub.$on).toHaveBeenCalledWith(
|
||||
`editor.update.model.dispose.${model.file.path}`,
|
||||
`editor.update.model.dispose.${model.file.key}`,
|
||||
jasmine.anything(),
|
||||
);
|
||||
});
|
||||
|
||||
describe('path', () => {
|
||||
it('returns file path', () => {
|
||||
expect(model.path).toBe('path');
|
||||
expect(model.path).toBe(model.file.key);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe('Multi-file editor library model', () => {
|
|||
model.onChange(() => {});
|
||||
|
||||
expect(model.events.size).toBe(1);
|
||||
expect(model.events.keys().next().value).toBe('path');
|
||||
expect(model.events.keys().next().value).toBe(model.file.key);
|
||||
});
|
||||
|
||||
it('calls callback on change', done => {
|
||||
|
@ -105,7 +105,7 @@ describe('Multi-file editor library model', () => {
|
|||
model.dispose();
|
||||
|
||||
expect(eventHub.$off).toHaveBeenCalledWith(
|
||||
`editor.update.model.dispose.${model.file.path}`,
|
||||
`editor.update.model.dispose.${model.file.key}`,
|
||||
jasmine.anything(),
|
||||
);
|
||||
});
|
||||
|
|
|
@ -131,7 +131,7 @@ describe('Multi-file editor library dirty diff controller', () => {
|
|||
it('adds decorations into decorations controller', () => {
|
||||
spyOn(controller.decorationsController, 'addDecorations');
|
||||
|
||||
controller.decorate({ data: { changes: [], path: 'path' } });
|
||||
controller.decorate({ data: { changes: [], path: model.path } });
|
||||
|
||||
expect(
|
||||
controller.decorationsController.addDecorations,
|
||||
|
@ -145,7 +145,7 @@ describe('Multi-file editor library dirty diff controller', () => {
|
|||
);
|
||||
|
||||
controller.decorate({
|
||||
data: { changes: computeDiff('123', '1234'), path: 'path' },
|
||||
data: { changes: computeDiff('123', '1234'), path: model.path },
|
||||
});
|
||||
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('Multi-file store file actions', () => {
|
|||
|
||||
it('closes open files', done => {
|
||||
store
|
||||
.dispatch('closeFile', localFile.path)
|
||||
.dispatch('closeFile', localFile)
|
||||
.then(() => {
|
||||
expect(localFile.opened).toBeFalsy();
|
||||
expect(localFile.active).toBeFalsy();
|
||||
|
@ -44,7 +44,7 @@ describe('Multi-file store file actions', () => {
|
|||
store.state.changedFiles.push(localFile);
|
||||
|
||||
store
|
||||
.dispatch('closeFile', localFile.path)
|
||||
.dispatch('closeFile', localFile)
|
||||
.then(Vue.nextTick)
|
||||
.then(() => {
|
||||
expect(store.state.openFiles.length).toBe(0);
|
||||
|
@ -65,7 +65,7 @@ describe('Multi-file store file actions', () => {
|
|||
store.state.entries[f.path] = f;
|
||||
|
||||
store
|
||||
.dispatch('closeFile', localFile.path)
|
||||
.dispatch('closeFile', localFile)
|
||||
.then(Vue.nextTick)
|
||||
.then(() => {
|
||||
expect(router.push).toHaveBeenCalledWith(`/project${f.url}`);
|
||||
|
|
Loading…
Reference in a new issue