diff options
author | Phil Hughes <me@iamphill.com> | 2018-03-21 10:05:08 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-03-22 10:33:19 +0000 |
commit | 51c64f3fc7180732621d60f939bfe6157165040f (patch) | |
tree | eaa1154ec945cfc289de9d2fd3f54a906d74d43b /spec/javascripts/ide/stores/mutations/file_spec.js | |
parent | 4718f22f5751f8d50bd7897ff4a967ccc5625c80 (diff) | |
download | gitlab-ce-51c64f3fc7180732621d60f939bfe6157165040f.tar.gz |
Added staged files state to IDE
Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/4541
Diffstat (limited to 'spec/javascripts/ide/stores/mutations/file_spec.js')
-rw-r--r-- | spec/javascripts/ide/stores/mutations/file_spec.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/javascripts/ide/stores/mutations/file_spec.js b/spec/javascripts/ide/stores/mutations/file_spec.js index 131380248e8..f769bedf50d 100644 --- a/spec/javascripts/ide/stores/mutations/file_spec.js +++ b/spec/javascripts/ide/stores/mutations/file_spec.js @@ -144,6 +144,72 @@ describe('Multi-file store file mutations', () => { }); }); + describe('STAGE_CHANGE', () => { + it('adds file into stagedFiles array', () => { + const f = file(); + + mutations.STAGE_CHANGE(localState, f); + + 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(); + }); + + it('updates stagedFile if it is already staged', () => { + const f = file(); + f.type = 'blob'; + + mutations.STAGE_CHANGE(localState, f); + + f.raw = 'testing 123'; + + mutations.STAGE_CHANGE(localState, f); + + expect(localState.stagedFiles.length).toBe(1); + expect(localState.stagedFiles[0].raw).toEqual('testing 123'); + }); + }); + + describe('UNSTAGE_CHANGE', () => { + let f; + + beforeEach(() => { + f = { + ...file(), + type: 'blob', + staged: true, + }; + + localState.stagedFiles.push(f); + localState.changedFiles.push(f); + }); + + it('removes from stagedFiles array', () => { + mutations.UNSTAGE_CHANGE(localState, f); + + expect(localState.stagedFiles.length).toBe(0); + }); + + it('updates changedFiles array file to unstaged', () => { + mutations.UNSTAGE_CHANGE(localState, f); + + expect(localState.changedFiles[0].staged).toBeFalsy(); + }); + }); + describe('TOGGLE_FILE_CHANGED', () => { it('updates file changed status', () => { mutations.TOGGLE_FILE_CHANGED(localState, { |