summaryrefslogtreecommitdiff
path: root/spec/javascripts/ide/components/repo_commit_section_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/ide/components/repo_commit_section_spec.js')
-rw-r--r--spec/javascripts/ide/components/repo_commit_section_spec.js50
1 files changed, 24 insertions, 26 deletions
diff --git a/spec/javascripts/ide/components/repo_commit_section_spec.js b/spec/javascripts/ide/components/repo_commit_section_spec.js
index 5e3e00a180b..30cd92b2ca4 100644
--- a/spec/javascripts/ide/components/repo_commit_section_spec.js
+++ b/spec/javascripts/ide/components/repo_commit_section_spec.js
@@ -1,6 +1,5 @@
import Vue from 'vue';
import store from '~/ide/stores';
-import service from '~/ide/services';
import router from '~/ide/ide_router';
import repoCommitSection from '~/ide/components/repo_commit_section.vue';
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
@@ -56,7 +55,7 @@ describe('RepoCommitSection', () => {
vm.$store.state.entries[f.path] = f;
});
- return vm.$mount();
+ return vm;
}
beforeEach(done => {
@@ -64,22 +63,9 @@ describe('RepoCommitSection', () => {
vm = createComponent();
- spyOn(service, 'getTreeData').and.returnValue(
- Promise.resolve({
- headers: {
- 'page-title': 'test',
- },
- json: () =>
- Promise.resolve({
- last_commit_path: 'last_commit_path',
- parent_tree_url: 'parent_tree_url',
- path: '/',
- trees: [{ name: 'tree' }],
- blobs: [{ name: 'blob' }],
- submodules: [{ name: 'submodule' }],
- }),
- }),
- );
+ spyOn(vm, 'openPendingTab').and.callThrough();
+
+ vm.$mount();
Vue.nextTick(done);
});
@@ -98,6 +84,7 @@ describe('RepoCommitSection', () => {
store.state.noChangesStateSvgPath = 'nochangessvg';
store.state.committedStateSvgPath = 'svg';
+ vm.$destroy();
vm = createComponentWithStore(Component, store).$mount();
expect(vm.$el.querySelector('.js-empty-state').textContent.trim()).toContain('No changes');
@@ -106,7 +93,7 @@ describe('RepoCommitSection', () => {
});
it('renders a commit section', () => {
- const changedFileElements = [...vm.$el.querySelectorAll('.multi-file-commit-list li')];
+ const changedFileElements = [...vm.$el.querySelectorAll('.multi-file-commit-list > li')];
const allFiles = vm.$store.state.changedFiles.concat(vm.$store.state.stagedFiles);
expect(changedFileElements.length).toEqual(4);
@@ -135,22 +122,26 @@ describe('RepoCommitSection', () => {
vm.$el.querySelector('.multi-file-discard-btn .btn').click();
Vue.nextTick(() => {
- expect(vm.$el.querySelector('.ide-commit-list-container').querySelectorAll('li').length).toBe(
- 1,
- );
+ expect(
+ vm.$el
+ .querySelector('.ide-commit-list-container')
+ .querySelectorAll('.multi-file-commit-list > li').length,
+ ).toBe(1);
done();
});
});
it('discards a single file', done => {
- vm.$el.querySelectorAll('.multi-file-discard-btn .btn')[1].click();
+ vm.$el.querySelector('.multi-file-discard-btn .dropdown-menu button').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.ide-commit-list-container').textContent).not.toContain('file1');
- expect(vm.$el.querySelector('.ide-commit-list-container').querySelectorAll('li').length).toBe(
- 1,
- );
+ expect(
+ vm.$el
+ .querySelector('.ide-commit-list-container')
+ .querySelectorAll('.multi-file-commit-list > li').length,
+ ).toBe(1);
done();
});
@@ -176,5 +167,12 @@ describe('RepoCommitSection', () => {
expect(store.state.openFiles.length).toBe(1);
expect(store.state.openFiles[0].pending).toBe(true);
});
+
+ it('calls openPendingTab', () => {
+ expect(vm.openPendingTab).toHaveBeenCalledWith({
+ file: vm.lastOpenedFile,
+ keyPrefix: 'unstaged',
+ });
+ });
});
});