Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-07-31 11:18:24 +0300
committerPhil Hughes <me@iamphill.com>2018-07-31 11:18:24 +0300
commit9712a6dd18bb2208c0e389bb0ab9464e711bfe97 (patch)
treefb24d04aa72f5815fe10159977fc6e0530925b0a /spec/javascripts
parentfd3ef2eb88d9d198d07c2761eac330e713a351b7 (diff)
specs
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/ide/stores/actions_spec.js54
-rw-r--r--spec/javascripts/ide/stores/mutations_spec.js97
-rw-r--r--spec/javascripts/ide/stores/utils_spec.js16
-rw-r--r--spec/javascripts/vue_shared/components/gl_modal_spec.js34
4 files changed, 194 insertions, 7 deletions
diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js
index 792a716565c..4a83d85b7a2 100644
--- a/spec/javascripts/ide/stores/actions_spec.js
+++ b/spec/javascripts/ide/stores/actions_spec.js
@@ -8,6 +8,7 @@ import actions, {
updateTempFlagForEntry,
setErrorMessage,
deleteEntry,
+ renameEntry,
} from '~/ide/stores/actions';
import store from '~/ide/stores';
import * as types from '~/ide/stores/mutation_types';
@@ -473,4 +474,57 @@ describe('Multi-file store actions', () => {
);
});
});
+
+ describe('renameEntry', () => {
+ it('renames entry', done => {
+ store.state.entries.test = {
+ tree: [],
+ };
+
+ testAction(
+ renameEntry,
+ { path: 'test', name: 'new-name' },
+ store.state,
+ [
+ {
+ type: types.RENAME_ENTRY,
+ payload: { path: 'test', name: 'new-name', entryPath: null },
+ },
+ ],
+ [{ type: 'deleteEntry', payload: 'test' }],
+ done,
+ );
+ });
+
+ it('renames all entries in tree', done => {
+ store.state.entries.test = {
+ tree: [
+ {
+ path: 'tree-1',
+ },
+ {
+ path: 'tree-2',
+ },
+ ],
+ };
+
+ testAction(
+ renameEntry,
+ { path: 'test', name: 'new-name' },
+ store.state,
+ [
+ {
+ type: types.RENAME_ENTRY,
+ payload: { path: 'test', name: 'new-name', entryPath: null },
+ },
+ ],
+ [
+ { type: 'renameEntry', payload: { path: 'test', name: 'new-name', entryPath: 'tree-1' } },
+ { type: 'renameEntry', payload: { path: 'test', name: 'new-name', entryPath: 'tree-2' } },
+ { type: 'deleteEntry', payload: 'test' },
+ ],
+ done,
+ );
+ });
+ });
});
diff --git a/spec/javascripts/ide/stores/mutations_spec.js b/spec/javascripts/ide/stores/mutations_spec.js
index 8b5f2d0bdfa..d15a1253d50 100644
--- a/spec/javascripts/ide/stores/mutations_spec.js
+++ b/spec/javascripts/ide/stores/mutations_spec.js
@@ -213,4 +213,101 @@ describe('Multi-file store mutations', () => {
expect(localState.changedFiles).toEqual([localState.entries.filePath]);
});
});
+
+ describe('UPDATE_FILE_AFTER_COMMIT', () => {
+ it('updates URLs if prevPath is set', () => {
+ const f = {
+ ...file(),
+ path: 'test',
+ prevPath: 'testing-123',
+ rawPath: `${gl.TEST_HOST}/testing-123`,
+ permalink: `${gl.TEST_HOST}/testing-123`,
+ commitsPath: `${gl.TEST_HOST}/testing-123`,
+ blamePath: `${gl.TEST_HOST}/testing-123`,
+ };
+ localState.entries.test = f;
+ localState.changedFiles.push(f);
+
+ mutations.UPDATE_FILE_AFTER_COMMIT(localState, { file: f, lastCommit: { commit: {} } });
+
+ expect(f.rawPath).toBe(`${gl.TEST_HOST}/test`);
+ expect(f.permalink).toBe(`${gl.TEST_HOST}/test`);
+ expect(f.commitsPath).toBe(`${gl.TEST_HOST}/test`);
+ expect(f.blamePath).toBe(`${gl.TEST_HOST}/test`);
+ });
+ });
+
+ describe('OPEN_NEW_ENTRY_MODAL', () => {
+ it('sets entryModal', () => {
+ localState.entries.testPath = {
+ ...file(),
+ };
+
+ mutations.OPEN_NEW_ENTRY_MODAL(localState, { type: 'test', path: 'testPath' });
+
+ expect(localState.entryModal).toEqual({
+ type: 'test',
+ path: 'testPath',
+ entry: localState.entries.testPath,
+ });
+ });
+ });
+
+ describe('RENAME_ENTRY', () => {
+ beforeEach(() => {
+ localState.trees = {
+ 'gitlab-ce/master': { tree: [] },
+ };
+ localState.currentProjectId = 'gitlab-ce';
+ localState.currentBranchId = 'master';
+ localState.entries.oldPath = {
+ ...file(),
+ type: 'blob',
+ path: 'oldPath',
+ url: `${gl.TEST_HOST}/oldPath`,
+ };
+ });
+
+ it('creates new renamed entry', () => {
+ mutations.RENAME_ENTRY(localState, { path: 'oldPath', name: 'newPath' });
+
+ expect(localState.entries.newPath).toEqual({
+ ...localState.entries.oldPath,
+ id: 'newPath',
+ name: 'newPath',
+ key: 'newPath-blob-name',
+ path: 'newPath',
+ tempFile: true,
+ prevPath: 'oldPath',
+ tree: [],
+ parentPath: '',
+ url: `${gl.TEST_HOST}/newPath`,
+ moved: jasmine.anything(),
+ });
+ });
+
+ it('adds new entry to changedFiles', () => {
+ mutations.RENAME_ENTRY(localState, { path: 'oldPath', name: 'newPath' });
+
+ expect(localState.changedFiles.length).toBe(1);
+ expect(localState.changedFiles[0].path).toBe('newPath');
+ });
+
+ it('sets oldEntry as moved', () => {
+ mutations.RENAME_ENTRY(localState, { path: 'oldPath', name: 'newPath' });
+
+ expect(localState.entries.oldPath.moved).toBe(true);
+ });
+
+ it('adds to parents tree', () => {
+ localState.entries.oldPath.parentPath = 'parentPath';
+ localState.entries.parentPath = {
+ ...file(),
+ };
+
+ mutations.RENAME_ENTRY(localState, { path: 'oldPath', name: 'newPath' });
+
+ expect(localState.entries.parentPath.tree.length).toBe(1);
+ });
+ });
});
diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js
index b7e0ec5392c..f1a3879ccea 100644
--- a/spec/javascripts/ide/stores/utils_spec.js
+++ b/spec/javascripts/ide/stores/utils_spec.js
@@ -232,6 +232,17 @@ describe('Multi-file store utils', () => {
},
],
},
+ {
+ path: 'c',
+ prevPath: 'x',
+ type: 'tree',
+ tree: [
+ {
+ path: 'c/index.js',
+ type: 'blob',
+ },
+ ],
+ },
];
const flattendFiles = utils.getCommitFiles(files);
@@ -252,6 +263,11 @@ describe('Multi-file store utils', () => {
type: 'blob',
deleted: true,
},
+ {
+ path: 'c/index.js',
+ type: 'blob',
+ deleted: true,
+ },
]);
});
});
diff --git a/spec/javascripts/vue_shared/components/gl_modal_spec.js b/spec/javascripts/vue_shared/components/gl_modal_spec.js
index e4737714312..263824a102a 100644
--- a/spec/javascripts/vue_shared/components/gl_modal_spec.js
+++ b/spec/javascripts/vue_shared/components/gl_modal_spec.js
@@ -29,7 +29,7 @@ describe('GlModal', () => {
describe('without id', () => {
beforeEach(() => {
- vm = mountComponent(modalComponent, { });
+ vm = mountComponent(modalComponent, {});
});
it('does not add an id attribute to the modal', () => {
@@ -83,7 +83,7 @@ describe('GlModal', () => {
});
});
- it('works with data-toggle="modal"', (done) => {
+ it('works with data-toggle="modal"', done => {
setFixtures(`
<button id="modal-button" data-toggle="modal" data-target="#my-modal"></button>
<div id="modal-container"></div>
@@ -91,9 +91,13 @@ describe('GlModal', () => {
const modalContainer = document.getElementById('modal-container');
const modalButton = document.getElementById('modal-button');
- vm = mountComponent(modalComponent, {
- id: 'my-modal',
- }, modalContainer);
+ vm = mountComponent(
+ modalComponent,
+ {
+ id: 'my-modal',
+ },
+ modalContainer,
+ );
$(vm.$el).on('shown.bs.modal', () => done());
modalButton.click();
@@ -103,7 +107,7 @@ describe('GlModal', () => {
const dummyEvent = 'not really an event';
beforeEach(() => {
- vm = mountComponent(modalComponent, { });
+ vm = mountComponent(modalComponent, {});
spyOn(vm, '$emit');
});
@@ -122,11 +126,27 @@ describe('GlModal', () => {
expect(vm.$emit).toHaveBeenCalledWith('submit', dummyEvent);
});
});
+
+ describe('opened', () => {
+ it('emits a open event', () => {
+ vm.opened();
+
+ expect(vm.$emit).toHaveBeenCalledWith('open');
+ });
+ });
+
+ describe('closed', () => {
+ it('emits a closed event', () => {
+ vm.closed();
+
+ expect(vm.$emit).toHaveBeenCalledWith('closed');
+ });
+ });
});
describe('slots', () => {
const slotContent = 'this should go into the slot';
- const modalWithSlot = (slotName) => {
+ const modalWithSlot = slotName => {
let template;
if (slotName) {
template = `