summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-03-21 12:43:59 +0000
committerPhil Hughes <me@iamphill.com>2018-03-22 10:33:20 +0000
commit4a4caa01fb09cd90c5be5264590629217cd26e16 (patch)
treeac289fde316ddac2862aeadf92c75048631f6c9e /spec
parentba63bda9550d3d66545e71de1f78a3089c7dc014 (diff)
downloadgitlab-ce-4a4caa01fb09cd90c5be5264590629217cd26e16.tar.gz
spec fixes
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js6
-rw-r--r--spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js4
-rw-r--r--spec/javascripts/ide/components/repo_commit_section_spec.js4
-rw-r--r--spec/javascripts/ide/stores/actions_spec.js37
-rw-r--r--spec/javascripts/ide/stores/modules/commit/actions_spec.js33
-rw-r--r--spec/javascripts/ide/stores/modules/commit/getters_spec.js10
-rw-r--r--spec/javascripts/ide/stores/mutations/file_spec.js44
7 files changed, 48 insertions, 90 deletions
diff --git a/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js b/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
index 6e34de1d959..6bf8710bda7 100644
--- a/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
+++ b/spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
@@ -13,7 +13,7 @@ describe('IDE stage file button', () => {
f = file();
vm = createComponentWithStore(Component, store, {
- file: f,
+ path: f.path,
});
spyOn(vm, 'stageChange');
@@ -35,12 +35,12 @@ describe('IDE stage file button', () => {
it('calls store with stage button', () => {
vm.$el.querySelectorAll('.btn')[0].click();
- expect(vm.stageChange).toHaveBeenCalledWith(f);
+ expect(vm.stageChange).toHaveBeenCalledWith(f.path);
});
it('calls store with discard button', () => {
vm.$el.querySelectorAll('.btn')[1].click();
- expect(vm.discardFileChanges).toHaveBeenCalledWith(f);
+ expect(vm.discardFileChanges).toHaveBeenCalledWith(f.path);
});
});
diff --git a/spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js b/spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
index 50fa1de2b44..917bbb9fb46 100644
--- a/spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
+++ b/spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
@@ -13,7 +13,7 @@ describe('IDE unstage file button', () => {
f = file();
vm = createComponentWithStore(Component, store, {
- file: f,
+ path: f.path,
});
spyOn(vm, 'unstageChange');
@@ -34,6 +34,6 @@ describe('IDE unstage file button', () => {
it('calls store with unnstage button', () => {
vm.$el.querySelector('.btn').click();
- expect(vm.unstageChange).toHaveBeenCalledWith(f);
+ expect(vm.unstageChange).toHaveBeenCalledWith(f.path);
});
});
diff --git a/spec/javascripts/ide/components/repo_commit_section_spec.js b/spec/javascripts/ide/components/repo_commit_section_spec.js
index c6c565bb0f3..768f6e99bf1 100644
--- a/spec/javascripts/ide/components/repo_commit_section_spec.js
+++ b/spec/javascripts/ide/components/repo_commit_section_spec.js
@@ -52,6 +52,10 @@ describe('RepoCommitSection', () => {
}),
);
+ vm.$store.state.changedFiles.forEach(f => {
+ vm.$store.state.entries[f.path] = f;
+ });
+
return vm.$mount();
}
diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js
index 0cbf9f3735f..5b5846f93df 100644
--- a/spec/javascripts/ide/stores/actions_spec.js
+++ b/spec/javascripts/ide/stores/actions_spec.js
@@ -298,6 +298,10 @@ describe('Multi-file store actions', () => {
store.state.changedFiles.push(f);
store.state.changedFiles.push(file('new'));
+ store.state.changedFiles.forEach(localFile => {
+ store.state.entries[localFile.path] = localFile;
+ });
+
store
.dispatch('stageAllChanges')
.then(() => {
@@ -308,23 +312,6 @@ describe('Multi-file store actions', () => {
})
.catch(done.fail);
});
-
- it('sets all files from changedFiles as staged after adding to stagedFiles', done => {
- store.state.changedFiles.push(file());
- store.state.changedFiles.push(file('new'));
-
- store
- .dispatch('stageAllChanges')
- .then(() => {
- expect(store.state.changedFiles.length).toBe(2);
- store.state.changedFiles.forEach(f => {
- expect(f.staged).toBeTruthy();
- });
-
- done();
- })
- .catch(done.fail);
- });
});
describe('unstageAllChanges', () => {
@@ -340,20 +327,10 @@ describe('Multi-file store actions', () => {
store.state.changedFiles.push({
...f,
});
- });
-
- it('sets staged to false in changedFiles when unstaging', done => {
- store.state.stagedFiles.push(f);
-
- store
- .dispatch('unstageAllChanges')
- .then(() => {
- expect(store.state.stagedFiles.length).toBe(0);
- expect(store.state.changedFiles[0].staged).toBeFalsy();
- done();
- })
- .catch(done.fail);
+ store.state.changedFiles.forEach(localFile => {
+ store.state.entries[localFile.path] = localFile;
+ });
});
it('removes all files from stagedFiles after unstaging', done => {
diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
index 780e46fe686..17fa7f8cba4 100644
--- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js
+++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
@@ -212,14 +212,14 @@ describe('IDE commit module actions', () => {
},
},
};
- store.state.changedFiles.push(f, {
+ store.state.stagedFiles.push(f, {
...file('changedFile2'),
changed: true,
});
- store.state.openFiles = store.state.changedFiles;
+ store.state.openFiles = store.state.stagedFiles;
- store.state.changedFiles.forEach(changedFile => {
- store.state.entries[changedFile.path] = changedFile;
+ store.state.stagedFiles.forEach(stagedFile => {
+ store.state.entries[stagedFile.path] = stagedFile;
});
});
@@ -253,19 +253,6 @@ describe('IDE commit module actions', () => {
.catch(done.fail);
});
- it('removes all changed files', done => {
- store
- .dispatch('commit/updateFilesAfterCommit', {
- data,
- branch,
- })
- .then(() => {
- expect(store.state.changedFiles.length).toBe(0);
- })
- .then(done)
- .catch(done.fail);
- });
-
it('sets files commit data', done => {
store
.dispatch('commit/updateFilesAfterCommit', {
@@ -301,7 +288,7 @@ describe('IDE commit module actions', () => {
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith(
`editor.update.model.content.${f.path}`,
- f.content,
+ { content: f.content, changed: false },
);
})
.then(done)
@@ -485,6 +472,16 @@ describe('IDE commit module actions', () => {
})
.catch(done.fail);
});
+
+ it('removes all staged files', done => {
+ store
+ .dispatch('commit/commitChanges')
+ .then(() => {
+ expect(store.state.stagedFiles.length).toBe(0);
+ })
+ .then(done)
+ .catch(done.fail);
+ });
});
describe('failed', () => {
diff --git a/spec/javascripts/ide/stores/modules/commit/getters_spec.js b/spec/javascripts/ide/stores/modules/commit/getters_spec.js
index e396284ec2c..55580f046ad 100644
--- a/spec/javascripts/ide/stores/modules/commit/getters_spec.js
+++ b/spec/javascripts/ide/stores/modules/commit/getters_spec.js
@@ -34,17 +34,17 @@ describe('IDE commit module getters', () => {
discardDraftButtonDisabled: false,
};
const rootState = {
- changedFiles: ['a'],
+ stagedFiles: ['a'],
};
- it('returns false when discardDraftButtonDisabled is false & changedFiles is not empty', () => {
+ it('returns false when discardDraftButtonDisabled is false & stagedFiles is not empty', () => {
expect(
getters.commitButtonDisabled(state, localGetters, rootState),
).toBeFalsy();
});
- it('returns true when discardDraftButtonDisabled is false & changedFiles is empty', () => {
- rootState.changedFiles.length = 0;
+ it('returns true when discardDraftButtonDisabled is false & stagedFiles is empty', () => {
+ rootState.stagedFiles.length = 0;
expect(
getters.commitButtonDisabled(state, localGetters, rootState),
@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
it('returns true when discardDraftButtonDisabled is false & changedFiles is not empty', () => {
localGetters.discardDraftButtonDisabled = false;
- rootState.changedFiles.length = 0;
+ rootState.stagedFiles.length = 0;
expect(
getters.commitButtonDisabled(state, localGetters, rootState),
diff --git a/spec/javascripts/ide/stores/mutations/file_spec.js b/spec/javascripts/ide/stores/mutations/file_spec.js
index f769bedf50d..3023b90e2e4 100644
--- a/spec/javascripts/ide/stores/mutations/file_spec.js
+++ b/spec/javascripts/ide/stores/mutations/file_spec.js
@@ -8,7 +8,10 @@ describe('Multi-file store file mutations', () => {
beforeEach(() => {
localState = state();
- localFile = file();
+ localFile = {
+ ...file(),
+ type: 'blob',
+ };
localState.entries[localFile.path] = localFile;
});
@@ -146,37 +149,18 @@ describe('Multi-file store file mutations', () => {
describe('STAGE_CHANGE', () => {
it('adds file into stagedFiles array', () => {
- const f = file();
-
- mutations.STAGE_CHANGE(localState, f);
+ mutations.STAGE_CHANGE(localState, localFile.path);
expect(localState.stagedFiles.length).toBe(1);
- expect(localState.stagedFiles[0]).toEqual(f);
- });
-
- it('updates changedFiles file to staged', () => {
- const f = {
- ...file(),
- type: 'blob',
- staged: false,
- };
-
- localState.changedFiles.push(f);
-
- mutations.STAGE_CHANGE(localState, f);
-
- expect(localState.changedFiles[0].staged).toBeTruthy();
+ expect(localState.stagedFiles[0]).toEqual(localFile);
});
it('updates stagedFile if it is already staged', () => {
- const f = file();
- f.type = 'blob';
+ mutations.STAGE_CHANGE(localState, localFile.path);
- mutations.STAGE_CHANGE(localState, f);
+ localFile.raw = 'testing 123';
- f.raw = 'testing 123';
-
- mutations.STAGE_CHANGE(localState, f);
+ mutations.STAGE_CHANGE(localState, localFile.path);
expect(localState.stagedFiles.length).toBe(1);
expect(localState.stagedFiles[0].raw).toEqual('testing 123');
@@ -195,18 +179,14 @@ describe('Multi-file store file mutations', () => {
localState.stagedFiles.push(f);
localState.changedFiles.push(f);
+ localState.entries[f.path] = f;
});
it('removes from stagedFiles array', () => {
- mutations.UNSTAGE_CHANGE(localState, f);
+ mutations.UNSTAGE_CHANGE(localState, f.path);
expect(localState.stagedFiles.length).toBe(0);
- });
-
- it('updates changedFiles array file to unstaged', () => {
- mutations.UNSTAGE_CHANGE(localState, f);
-
- expect(localState.changedFiles[0].staged).toBeFalsy();
+ expect(localState.changedFiles.length).toBe(1);
});
});