2018-10-15 14:42:47 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import store from '~/ide/stores';
|
|
|
|
import stageButton from '~/ide/components/commit_sidebar/stage_button.vue';
|
|
|
|
import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper';
|
|
|
|
import { file, resetStore } from '../../helpers';
|
|
|
|
|
|
|
|
describe('IDE stage file button', () => {
|
|
|
|
let vm;
|
|
|
|
let f;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(stageButton);
|
|
|
|
f = file();
|
|
|
|
|
|
|
|
vm = createComponentWithStore(Component, store, {
|
|
|
|
path: f.path,
|
|
|
|
});
|
|
|
|
|
|
|
|
spyOn(vm, 'stageChange');
|
|
|
|
spyOn(vm, 'discardFileChanges');
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
|
|
|
|
resetStore(vm.$store);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders button to discard & stage', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(vm.$el.querySelectorAll('.btn-blank').length).toBe(2);
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('calls store with stage button', () => {
|
|
|
|
vm.$el.querySelectorAll('.btn')[0].click();
|
|
|
|
|
|
|
|
expect(vm.stageChange).toHaveBeenCalledWith(f.path);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calls store with discard button', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
vm.$el.querySelector('.btn-danger').click();
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
expect(vm.discardFileChanges).toHaveBeenCalledWith(f.path);
|
|
|
|
});
|
|
|
|
});
|