Commit f489fa2a authored by Phil Hughes's avatar Phil Hughes

fixed karma specs

parent eeb41af7
...@@ -3,7 +3,6 @@ import store from '~/ide/stores'; ...@@ -3,7 +3,6 @@ import store from '~/ide/stores';
import service from '~/ide/services'; import service from '~/ide/services';
import repoCommitSection from '~/ide/components/repo_commit_section.vue'; import repoCommitSection from '~/ide/components/repo_commit_section.vue';
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import getSetTimeoutPromise from 'spec/helpers/set_timeout_promise_helper';
import { file, resetStore } from '../helpers'; import { file, resetStore } from '../helpers';
describe('RepoCommitSection', () => { describe('RepoCommitSection', () => {
...@@ -105,30 +104,28 @@ describe('RepoCommitSection', () => { ...@@ -105,30 +104,28 @@ describe('RepoCommitSection', () => {
it('renders a commit section', () => { 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 submitCommit = vm.$el.querySelector('form .btn');
const allFiles = vm.$store.state.changedFiles.concat(vm.$store.state.stagedFiles); const allFiles = vm.$store.state.changedFiles.concat(vm.$store.state.stagedFiles);
expect(vm.$el.querySelector('.multi-file-commit-form')).not.toBeNull();
expect(changedFileElements.length).toEqual(4); expect(changedFileElements.length).toEqual(4);
changedFileElements.forEach((changedFile, i) => { changedFileElements.forEach((changedFile, i) => {
expect(changedFile.textContent.trim()).toContain(allFiles[i].path); expect(changedFile.textContent.trim()).toContain(allFiles[i].path);
}); });
expect(submitCommit.disabled).toBeTruthy();
expect(submitCommit.querySelector('.fa-spinner.fa-spin')).toBeNull();
}); });
it('adds changed files into staged files', done => { it('adds changed files into staged files', done => {
vm.$el.querySelector('.ide-staged-action-btn').click(); vm.$el.querySelector('.multi-file-discard-btn .btn').click();
vm
Vue.nextTick(() => { .$nextTick()
expect(vm.$el.querySelector('.ide-commit-list-container').textContent).toContain( .then(() => vm.$el.querySelector('.multi-file-discard-btn .btn').click())
'No changes', .then(vm.$nextTick)
); .then(() => {
expect(vm.$el.querySelector('.ide-commit-list-container').textContent).toContain(
done(); 'No changes',
}); );
})
.then(done)
.catch(done.fail);
}); });
it('stages a single file', done => { it('stages a single file', done => {
...@@ -156,18 +153,6 @@ describe('RepoCommitSection', () => { ...@@ -156,18 +153,6 @@ describe('RepoCommitSection', () => {
}); });
}); });
it('removes all staged files', done => {
vm.$el.querySelectorAll('.ide-staged-action-btn')[1].click();
Vue.nextTick(() => {
expect(vm.$el.querySelectorAll('.ide-commit-list-container')[1].textContent).toContain(
'No changes',
);
done();
});
});
it('unstages a single file', done => { it('unstages a single file', done => {
vm.$el vm.$el
.querySelectorAll('.multi-file-discard-btn')[2] .querySelectorAll('.multi-file-discard-btn')[2]
......
...@@ -267,41 +267,23 @@ describe('IDE store file mutations', () => { ...@@ -267,41 +267,23 @@ describe('IDE store file mutations', () => {
it('adds file into openFiles as pending', () => { it('adds file into openFiles as pending', () => {
mutations.ADD_PENDING_TAB(localState, { file: localFile }); mutations.ADD_PENDING_TAB(localState, { file: localFile });
expect(localState.openFiles.length).toBe(2);
expect(localState.openFiles[1].pending).toBe(true);
expect(localState.openFiles[1].key).toBe(`pending-${localFile.key}`);
});
it('updates open file to pending', () => {
mutations.ADD_PENDING_TAB(localState, { file: localState.openFiles[0] });
expect(localState.openFiles.length).toBe(1); expect(localState.openFiles.length).toBe(1);
expect(localState.openFiles[0].pending).toBe(true);
expect(localState.openFiles[0].key).toBe(`pending-${localFile.key}`);
}); });
it('updates pending open file to active', () => { it('only allows 1 open pending file', () => {
localState.openFiles.push({ const newFile = file('test');
...localFile, localState.entries[newFile.path] = newFile;
pending: true,
});
mutations.ADD_PENDING_TAB(localState, { file: localFile }); mutations.ADD_PENDING_TAB(localState, { file: localFile });
expect(localState.openFiles[1].pending).toBe(true); expect(localState.openFiles.length).toBe(1);
expect(localState.openFiles[1].active).toBe(true);
});
it('sets all openFiles to not active', () => {
mutations.ADD_PENDING_TAB(localState, { file: localFile });
expect(localState.openFiles.length).toBe(2); mutations.ADD_PENDING_TAB(localState, { file: file('test') });
localState.openFiles.forEach(f => { expect(localState.openFiles.length).toBe(1);
if (f.pending) { expect(localState.openFiles[0].name).toBe('test');
expect(f.active).toBe(true);
} else {
expect(f.active).toBe(false);
}
});
}); });
}); });
......
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