diff options
author | Phil Hughes <me@iamphill.com> | 2018-06-25 14:51:45 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-06-26 16:52:33 +0100 |
commit | 776eb192e89335946a4983098ad07dad1931eef5 (patch) | |
tree | ff5c9445306f7d0e109792f26d3488d6c76285b8 | |
parent | 6c1cc76c248045b3f12aaeb6f4b861c0545dabb0 (diff) | |
download | gitlab-ce-ide-commit-form-improvements.tar.gz |
:white_check_mark: added specside-commit-form-improvements
4 files changed, 100 insertions, 0 deletions
diff --git a/spec/javascripts/ide/components/commit_sidebar/form_spec.js b/spec/javascripts/ide/components/commit_sidebar/form_spec.js index 0a20b3b088f..b7a7afe4db4 100644 --- a/spec/javascripts/ide/components/commit_sidebar/form_spec.js +++ b/spec/javascripts/ide/components/commit_sidebar/form_spec.js @@ -147,4 +147,16 @@ describe('IDE commit form', () => { }); }); }); + + describe('commitButtonText', () => { + it('returns commit text when staged files exist', () => { + vm.$store.state.stagedFiles.push('testing'); + + expect(vm.commitButtonText).toBe('Commit'); + }); + + it('returns stage & commit text when staged files do not exist', () => { + expect(vm.commitButtonText).toBe('Stage & Commit'); + }); + }); }); diff --git a/spec/javascripts/ide/components/commit_sidebar/radio_group_spec.js b/spec/javascripts/ide/components/commit_sidebar/radio_group_spec.js index 21bfe4be52f..ffc2a4c9ddb 100644 --- a/spec/javascripts/ide/components/commit_sidebar/radio_group_spec.js +++ b/spec/javascripts/ide/components/commit_sidebar/radio_group_spec.js @@ -114,4 +114,19 @@ describe('IDE commit sidebar radio group', () => { }); }); }); + + describe('tooltipTitle', () => { + it('returns title when disabled', () => { + vm.title = 'test title'; + vm.disabled = true; + + expect(vm.tooltipTitle).toBe('test title'); + }); + + it('returns blank when not disabled', () => { + vm.title = 'test title'; + + expect(vm.tooltipTitle).not.toBe('test title'); + }); + }); }); diff --git a/spec/javascripts/ide/stores/getters_spec.js b/spec/javascripts/ide/stores/getters_spec.js index 00317e15dbc..70883e16b0d 100644 --- a/spec/javascripts/ide/stores/getters_spec.js +++ b/spec/javascripts/ide/stores/getters_spec.js @@ -160,4 +160,23 @@ describe('IDE store getters', () => { expect(getters.lastCommit(localState, localGetters).title).toBe(commitTitle); }); }); + + describe('currentBranch', () => { + it('returns current projects branch', () => { + const localGetters = { + currentProject: { + branches: { + master: { + name: 'master', + }, + }, + }, + }; + localState.currentBranchId = 'master'; + + expect(getters.currentBranch(localState, localGetters)).toEqual({ + name: 'master', + }); + }); + }); }); diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js index a7bd443af51..6c5980cfae4 100644 --- a/spec/javascripts/ide/stores/utils_spec.js +++ b/spec/javascripts/ide/stores/utils_spec.js @@ -94,6 +94,7 @@ describe('Multi-file store utils', () => { newBranch: false, state, rootState, + getters: {}, }); expect(payload).toEqual({ @@ -118,5 +119,58 @@ describe('Multi-file store utils', () => { start_branch: undefined, }); }); + + it('uses prebuilt commit message when commit message is empty', () => { + const rootState = { + stagedFiles: [ + { + ...file('staged'), + path: 'staged', + content: 'updated file content', + lastCommitSha: '123456789', + }, + { + ...file('newFile'), + path: 'added', + tempFile: true, + content: 'new file content', + base64: true, + lastCommitSha: '123456789', + }, + ], + currentBranchId: 'master', + }; + const payload = utils.createCommitPayload({ + branch: 'master', + newBranch: false, + state: {}, + rootState, + getters: { + preBuiltCommitMessage: 'prebuilt test commit message', + }, + }); + + expect(payload).toEqual({ + branch: 'master', + commit_message: 'prebuilt test commit message', + actions: [ + { + action: 'update', + file_path: 'staged', + content: 'updated file content', + encoding: 'text', + last_commit_id: '123456789', + }, + { + action: 'create', + file_path: 'added', + content: 'new file content', + encoding: 'base64', + last_commit_id: '123456789', + }, + ], + start_branch: undefined, + }); + }); }); }); |