summaryrefslogtreecommitdiff
path: root/spec/javascripts/ide/stores/actions/file_spec.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-04-03 11:10:01 +0100
committerPhil Hughes <me@iamphill.com>2018-04-03 11:10:01 +0100
commit49f198e6c142c0bf6983187b164599388cd67197 (patch)
treef103b1914c092480af36c200ca75813d6b132434 /spec/javascripts/ide/stores/actions/file_spec.js
parentd6dd2f5f70685e35cf6d0f2738059fe44e1054a3 (diff)
parent8dca091ff7f04bb92a7835ebeff783b7f0ef76cd (diff)
downloadgitlab-ce-49f198e6c142c0bf6983187b164599388cd67197.tar.gz
Merge branch 'master' into ide-staged-changes
Diffstat (limited to 'spec/javascripts/ide/stores/actions/file_spec.js')
-rw-r--r--spec/javascripts/ide/stores/actions/file_spec.js43
1 files changed, 35 insertions, 8 deletions
diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js
index 5de09f1faae..08d39fe1ca4 100644
--- a/spec/javascripts/ide/stores/actions/file_spec.js
+++ b/spec/javascripts/ide/stores/actions/file_spec.js
@@ -8,7 +8,7 @@ import eventHub from '~/ide/eventhub';
import { file, resetStore } from '../../helpers';
import testAction from '../../../helpers/vuex_action_helper';
-describe('Multi-file store file actions', () => {
+describe('IDE store file actions', () => {
beforeEach(() => {
spyOn(router, 'push');
});
@@ -192,7 +192,7 @@ describe('Multi-file store file actions', () => {
it('calls the service', done => {
store
- .dispatch('getFileData', localFile)
+ .dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(service.getFileData).toHaveBeenCalledWith('getFileDataURL');
@@ -203,7 +203,7 @@ describe('Multi-file store file actions', () => {
it('sets the file data', done => {
store
- .dispatch('getFileData', localFile)
+ .dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(localFile.blamePath).toBe('blame_path');
@@ -214,7 +214,7 @@ describe('Multi-file store file actions', () => {
it('sets document title', done => {
store
- .dispatch('getFileData', localFile)
+ .dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(document.title).toBe('testing getFileData');
@@ -225,7 +225,7 @@ describe('Multi-file store file actions', () => {
it('sets the file as active', done => {
store
- .dispatch('getFileData', localFile)
+ .dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(localFile.active).toBeTruthy();
@@ -234,9 +234,20 @@ describe('Multi-file store file actions', () => {
.catch(done.fail);
});
+ it('sets the file not as active if we pass makeFileActive false', done => {
+ store
+ .dispatch('getFileData', { path: localFile.path, makeFileActive: false })
+ .then(() => {
+ expect(localFile.active).toBeFalsy();
+
+ done();
+ })
+ .catch(done.fail);
+ });
+
it('adds the file to open files', done => {
store
- .dispatch('getFileData', localFile)
+ .dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(store.state.openFiles.length).toBe(1);
expect(store.state.openFiles[0].name).toBe(localFile.name);
@@ -259,7 +270,7 @@ describe('Multi-file store file actions', () => {
it('calls getRawFileData service method', done => {
store
- .dispatch('getRawFileData', tmpFile)
+ .dispatch('getRawFileData', { path: tmpFile.path })
.then(() => {
expect(service.getRawFileData).toHaveBeenCalledWith(tmpFile);
@@ -270,7 +281,7 @@ describe('Multi-file store file actions', () => {
it('updates file raw data', done => {
store
- .dispatch('getRawFileData', tmpFile)
+ .dispatch('getRawFileData', { path: tmpFile.path })
.then(() => {
expect(tmpFile.raw).toBe('raw');
@@ -278,6 +289,22 @@ describe('Multi-file store file actions', () => {
})
.catch(done.fail);
});
+
+ it('calls also getBaseRawFileData service method', done => {
+ spyOn(service, 'getBaseRawFileData').and.returnValue(Promise.resolve('baseraw'));
+
+ tmpFile.mrChange = { new_file: false };
+
+ store
+ .dispatch('getRawFileData', { path: tmpFile.path, baseSha: 'SHA' })
+ .then(() => {
+ expect(service.getBaseRawFileData).toHaveBeenCalledWith(tmpFile, 'SHA');
+ expect(tmpFile.baseRaw).toBe('baseraw');
+
+ done();
+ })
+ .catch(done.fail);
+ });
});
describe('changeFileContent', () => {