diff options
Diffstat (limited to 'spec/javascripts/ide/stores/actions/file_spec.js')
-rw-r--r-- | spec/javascripts/ide/stores/actions/file_spec.js | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js index 479ed7ce49e..3ee11bd2f03 100644 --- a/spec/javascripts/ide/stores/actions/file_spec.js +++ b/spec/javascripts/ide/stores/actions/file_spec.js @@ -1,9 +1,12 @@ import Vue from 'vue'; import store from '~/ide/stores'; +import * as actions from '~/ide/stores/actions/file'; +import * as types from '~/ide/stores/mutation_types'; import service from '~/ide/services'; import router from '~/ide/ide_router'; import eventHub from '~/ide/eventhub'; import { file, resetStore } from '../../helpers'; +import testAction from '../../../helpers/vuex_action_helper'; describe('IDE store file actions', () => { beforeEach(() => { @@ -395,6 +398,20 @@ describe('IDE store file actions', () => { }) .catch(done.fail); }); + + it('bursts unused seal', done => { + store + .dispatch('changeFileContent', { + path: tmpFile.path, + content: 'content', + }) + .then(() => { + expect(store.state.unusedSeal).toBe(false); + + done(); + }) + .catch(done.fail); + }); }); describe('discardFileChanges', () => { @@ -402,6 +419,7 @@ describe('IDE store file actions', () => { beforeEach(() => { spyOn(eventHub, '$on'); + spyOn(eventHub, '$emit'); tmpFile = file(); tmpFile.content = 'testing'; @@ -460,6 +478,57 @@ describe('IDE store file actions', () => { }) .catch(done.fail); }); + + it('pushes route for active file', done => { + tmpFile.active = true; + store.state.openFiles.push(tmpFile); + + store + .dispatch('discardFileChanges', tmpFile.path) + .then(() => { + expect(router.push).toHaveBeenCalledWith(`/project${tmpFile.url}`); + + done(); + }) + .catch(done.fail); + }); + + it('emits eventHub event to dispose cached model', done => { + store + .dispatch('discardFileChanges', tmpFile.path) + .then(() => { + expect(eventHub.$emit).toHaveBeenCalled(); + + done(); + }) + .catch(done.fail); + }); + }); + + describe('stageChange', () => { + it('calls STAGE_CHANGE with file path', done => { + testAction( + actions.stageChange, + 'path', + store.state, + [{ type: types.STAGE_CHANGE, payload: 'path' }], + [], + done, + ); + }); + }); + + describe('unstageChange', () => { + it('calls UNSTAGE_CHANGE with file path', done => { + testAction( + actions.unstageChange, + 'path', + store.state, + [{ type: types.UNSTAGE_CHANGE, payload: 'path' }], + [], + done, + ); + }); }); describe('openPendingTab', () => { @@ -476,7 +545,7 @@ describe('IDE store file actions', () => { it('makes file pending in openFiles', done => { store - .dispatch('openPendingTab', f) + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) .then(() => { expect(store.state.openFiles[0].pending).toBe(true); }) @@ -486,7 +555,7 @@ describe('IDE store file actions', () => { it('returns true when opened', done => { store - .dispatch('openPendingTab', f) + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) .then(added => { expect(added).toBe(true); }) @@ -498,7 +567,7 @@ describe('IDE store file actions', () => { store.state.currentBranchId = 'master'; store - .dispatch('openPendingTab', f) + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) .then(() => { expect(router.push).toHaveBeenCalledWith('/project/123/tree/master/'); }) @@ -512,7 +581,7 @@ describe('IDE store file actions', () => { store._actions.scrollToTab = [scrollToTabSpy]; // eslint-disable-line store - .dispatch('openPendingTab', f) + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) .then(() => { expect(scrollToTabSpy).toHaveBeenCalled(); store._actions.scrollToTab = oldScrollToTab; // eslint-disable-line @@ -527,7 +596,7 @@ describe('IDE store file actions', () => { store.state.viewer = 'diff'; store - .dispatch('openPendingTab', f) + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) .then(added => { expect(added).toBe(false); }) |