Commit 7c20403f authored by Phil Hughes's avatar Phil Hughes

fixed failing tests because of passed `null`

added spec to check for `head` file
parent 4581a78d
...@@ -19,7 +19,7 @@ export default { ...@@ -19,7 +19,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapState(['rightPanelCollapsed', 'viewer', 'delayViewerUpdated']), ...mapState(['rightPanelCollapsed', 'viewer', 'delayViewerUpdated', 'panelResizing']),
...mapGetters(['currentMergeRequest', 'getStagedFile']), ...mapGetters(['currentMergeRequest', 'getStagedFile']),
shouldHideEditor() { shouldHideEditor() {
return this.file && this.file.binary && !this.file.raw; return this.file && this.file.binary && !this.file.raw;
......
...@@ -163,7 +163,7 @@ describe('RepoEditor', () => { ...@@ -163,7 +163,7 @@ describe('RepoEditor', () => {
vm.setupEditor(); vm.setupEditor();
expect(vm.editor.createModel).toHaveBeenCalledWith(vm.file); expect(vm.editor.createModel).toHaveBeenCalledWith(vm.file, null);
expect(vm.model).not.toBeNull(); expect(vm.model).not.toBeNull();
}); });
...@@ -197,6 +197,20 @@ describe('RepoEditor', () => { ...@@ -197,6 +197,20 @@ describe('RepoEditor', () => {
done(); done();
}); });
}); });
it('sets head model as staged file', () => {
spyOn(vm.editor, 'createModel').and.callThrough();
Editor.editorInstance.modelManager.dispose();
vm.$store.state.stagedFiles.push({ ...vm.file, key: 'staged' });
vm.file.staged = true;
vm.file.key = `unstaged-${vm.file.key}`;
vm.setupEditor();
expect(vm.editor.createModel).toHaveBeenCalledWith(vm.file, vm.$store.state.stagedFiles[0]);
});
}); });
describe('editor updateDimensions', () => { describe('editor updateDimensions', () => {
......
...@@ -30,6 +30,19 @@ describe('Multi-file editor library model', () => { ...@@ -30,6 +30,19 @@ describe('Multi-file editor library model', () => {
expect(model.baseModel).not.toBeNull(); expect(model.baseModel).not.toBeNull();
}); });
it('creates model with head file to compare against', () => {
const f = file('path');
model.dispose();
model = new Model(monaco, f, {
...f,
content: '123 testing',
});
expect(model.head).not.toBeNull();
expect(model.getOriginalModel().getValue()).toBe('123 testing');
});
it('adds eventHub listener', () => { it('adds eventHub listener', () => {
expect(eventHub.$on).toHaveBeenCalledWith( expect(eventHub.$on).toHaveBeenCalledWith(
`editor.update.model.dispose.${model.file.key}`, `editor.update.model.dispose.${model.file.key}`,
......
...@@ -88,7 +88,7 @@ describe('Multi-file editor library', () => { ...@@ -88,7 +88,7 @@ describe('Multi-file editor library', () => {
instance.createModel('FILE'); instance.createModel('FILE');
expect(instance.modelManager.addModel).toHaveBeenCalledWith('FILE'); expect(instance.modelManager.addModel).toHaveBeenCalledWith('FILE', null);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment