Commit 8186bb39 authored by Filipa Lacerda's avatar Filipa Lacerda

Removes unused store in diffs mr refactor

Removes double export for actions in diffs module in mr refactor
parent acdac151
...@@ -82,14 +82,5 @@ export const expandAllFiles = ({ commit }) => { ...@@ -82,14 +82,5 @@ export const expandAllFiles = ({ commit }) => {
commit(types.EXPAND_ALL_FILES); commit(types.EXPAND_ALL_FILES);
}; };
export default { // prevent babel-plugin-rewire from generating an invalid default during karma tests
setBaseConfig, export default () => {};
fetchDiffFiles,
setInlineDiffViewType,
setParallelDiffViewType,
showCommentForm,
cancelCommentForm,
loadMoreLines,
loadCollapsedDiff,
expandAllFiles,
};
import Vue from 'vue';
import Vuex from 'vuex';
import diffsModule from './modules';
Vue.use(Vuex);
export default new Vuex.Store({
modules: {
diffs: diffsModule,
},
});
import actions from '../actions'; import * as actions from '../actions';
import * as getters from '../getters'; import * as getters from '../getters';
import mutations from '../mutations'; import mutations from '../mutations';
import createState from './diff_state'; import createState from './diff_state';
......
---
title: Removes unused vuex code in mr refactor and removes unneeded dependencies
merge_request: 20499
author:
type: other
import Vue from 'vue'; import Vue from 'vue';
import $ from 'jquery'; import Vuex from 'vuex';
import { mountComponentWithStore } from 'spec/helpers'; import { mountComponentWithStore } from 'spec/helpers';
import store from '~/diffs/store'; import diffsModule from '~/diffs/store/modules';
import ChangedFiles from '~/diffs/components/changed_files.vue'; import changedFiles from '~/diffs/components/changed_files.vue';
describe('ChangedFiles', () => { describe('ChangedFiles', () => {
const Component = Vue.extend(ChangedFiles); const Component = Vue.extend(changedFiles);
const createComponent = props => mountComponentWithStore(Component, { props, store }); const store = new Vuex.Store({
modules: {
diffs: diffsModule,
},
});
let vm; let vm;
beforeEach(() => { beforeEach(() => {
...@@ -14,6 +19,7 @@ describe('ChangedFiles', () => { ...@@ -14,6 +19,7 @@ describe('ChangedFiles', () => {
<div id="dummy-element"></div> <div id="dummy-element"></div>
<div class="js-tabs-affix"></div> <div class="js-tabs-affix"></div>
`); `);
const props = { const props = {
diffFiles: [ diffFiles: [
{ {
...@@ -26,7 +32,8 @@ describe('ChangedFiles', () => { ...@@ -26,7 +32,8 @@ describe('ChangedFiles', () => {
}, },
], ],
}; };
vm = createComponent(props);
vm = mountComponentWithStore(Component, { props, store });
}); });
describe('with single file added', () => { describe('with single file added', () => {
...@@ -40,58 +47,56 @@ describe('ChangedFiles', () => { ...@@ -40,58 +47,56 @@ describe('ChangedFiles', () => {
}); });
}); });
describe('template', () => { describe('diff view mode buttons', () => {
describe('diff view mode buttons', () => { let inlineButton;
let inlineButton; let parallelButton;
let parallelButton;
beforeEach(() => { beforeEach(() => {
inlineButton = vm.$el.querySelector('.js-inline-diff-button'); inlineButton = vm.$el.querySelector('.js-inline-diff-button');
parallelButton = vm.$el.querySelector('.js-parallel-diff-button'); parallelButton = vm.$el.querySelector('.js-parallel-diff-button');
}); });
it('should have Inline and Side-by-side buttons', () => {
expect(inlineButton).toBeDefined();
expect(parallelButton).toBeDefined();
});
it('should add active class to Inline button', done => {
vm.$store.state.diffs.diffViewType = 'inline';
vm.$nextTick(() => {
expect(inlineButton.classList.contains('active')).toEqual(true);
expect(parallelButton.classList.contains('active')).toEqual(false);
it('should have Inline and Side-by-side buttons', () => { done();
expect(inlineButton).toBeDefined();
expect(parallelButton).toBeDefined();
}); });
});
it('should add active class to Inline button', done => { it('should toggle active state of buttons when diff view type changed', done => {
vm.$store.state.diffs.diffViewType = 'inline'; vm.$store.state.diffs.diffViewType = 'parallel';
vm.$nextTick(() => { vm.$nextTick(() => {
expect(inlineButton.classList.contains('active')).toEqual(true); expect(inlineButton.classList.contains('active')).toEqual(false);
expect(parallelButton.classList.contains('active')).toEqual(false); expect(parallelButton.classList.contains('active')).toEqual(true);
done(); done();
});
}); });
});
it('should toggle active state of buttons when diff view type changed', done => { describe('clicking them', () => {
vm.$store.state.diffs.diffViewType = 'parallel'; it('should toggle the diff view type', done => {
parallelButton.click();
vm.$nextTick(() => { vm.$nextTick(() => {
expect(inlineButton.classList.contains('active')).toEqual(false); expect(inlineButton.classList.contains('active')).toEqual(false);
expect(parallelButton.classList.contains('active')).toEqual(true); expect(parallelButton.classList.contains('active')).toEqual(true);
done(); inlineButton.click();
});
});
describe('clicking them', () => {
it('should toggle the diff view type', done => {
$(parallelButton).click();
vm.$nextTick(() => { vm.$nextTick(() => {
expect(inlineButton.classList.contains('active')).toEqual(false); expect(inlineButton.classList.contains('active')).toEqual(true);
expect(parallelButton.classList.contains('active')).toEqual(true); expect(parallelButton.classList.contains('active')).toEqual(false);
done();
$(inlineButton).click();
vm.$nextTick(() => {
expect(inlineButton.classList.contains('active')).toEqual(true);
expect(parallelButton.classList.contains('active')).toEqual(false);
done();
});
}); });
}); });
}); });
......
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