diff options
author | Phil Hughes <me@iamphill.com> | 2018-03-29 15:16:19 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-03-29 15:16:19 +0100 |
commit | d6dd2f5f70685e35cf6d0f2738059fe44e1054a3 (patch) | |
tree | 7b97644cd014975681d75b8c683f52e7b27293dc /spec/javascripts/ide/stores/actions_spec.js | |
parent | aaa7dbb4b6cd1ac7a9a5d4eddcd3ecb23ef870ac (diff) | |
download | gitlab-ce-d6dd2f5f70685e35cf6d0f2738059fe44e1054a3.tar.gz |
updated tests to use testAction helper
Diffstat (limited to 'spec/javascripts/ide/stores/actions_spec.js')
-rw-r--r-- | spec/javascripts/ide/stores/actions_spec.js | 76 |
1 files changed, 28 insertions, 48 deletions
diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js index 5b5846f93df..ce8d11c9c69 100644 --- a/spec/javascripts/ide/stores/actions_spec.js +++ b/spec/javascripts/ide/stores/actions_spec.js @@ -1,7 +1,10 @@ import * as urlUtils from '~/lib/utils/url_utility'; import store from '~/ide/stores'; +import * as actions from '~/ide/stores/actions'; +import * as types from '~/ide/stores/mutation_types'; import router from '~/ide/ide_router'; import { resetStore, file } from '../helpers'; +import testAction from '../../helpers/vuex_action_helper'; describe('Multi-file store actions', () => { beforeEach(() => { @@ -191,9 +194,7 @@ describe('Multi-file store actions', () => { }) .then(f => { expect(f.tempFile).toBeTruthy(); - expect(store.state.trees['abcproject/mybranch'].tree.length).toBe( - 1, - ); + expect(store.state.trees['abcproject/mybranch'].tree.length).toBe(1); done(); }) @@ -294,56 +295,35 @@ describe('Multi-file store actions', () => { describe('stageAllChanges', () => { it('adds all files from changedFiles to stagedFiles', done => { - const f = file(); - 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(() => { - expect(store.state.stagedFiles.length).toBe(2); - expect(store.state.stagedFiles[0]).toEqual(f); - - done(); - }) - .catch(done.fail); + store.state.changedFiles.push(file(), file('new')); + + testAction( + actions.stageAllChanges, + null, + store.state, + [ + { type: types.STAGE_CHANGE, payload: store.state.changedFiles[0].path }, + { type: types.STAGE_CHANGE, payload: store.state.changedFiles[1].path }, + ], + done, + ); }); }); describe('unstageAllChanges', () => { - let f; - - beforeEach(() => { - f = { - ...file(), - type: 'blob', - staged: true, - }; - - store.state.changedFiles.push({ - ...f, - }); - - store.state.changedFiles.forEach(localFile => { - store.state.entries[localFile.path] = localFile; - }); - }); - it('removes all files from stagedFiles after unstaging', done => { - store.state.stagedFiles.push(file()); - - store - .dispatch('unstageAllChanges') - .then(() => { - expect(store.state.stagedFiles.length).toBe(0); - - done(); - }) - .catch(done.fail); + store.state.stagedFiles.push(file(), file('new')); + + testAction( + actions.unstageAllChanges, + null, + store.state, + [ + { type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[0].path }, + { type: types.UNSTAGE_CHANGE, payload: store.state.stagedFiles[1].path }, + ], + done, + ); }); }); |