summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-05-04 13:40:41 +0100
committerPhil Hughes <me@iamphill.com>2018-05-04 13:40:41 +0100
commit80617b9039ccbeeec07e299e41690be6ce2d95ec (patch)
treedc34efce00b956309c147ea59a786b58b47805b6 /spec/javascripts
parentcb8682b841b92cb6f97906bb9289ccbb13f2f31e (diff)
parentd9f3af500c1c3135a63014904459e5a4ab6bc395 (diff)
downloadgitlab-ce-80617b9039ccbeeec07e299e41690be6ce2d95ec.tar.gz
Merge branch '44846-improve-web-ide-left-panel-and-modes' into ide-sidebar-commit-box
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/ide/components/repo_file_spec.js27
-rw-r--r--spec/javascripts/ide/stores/getters_spec.js63
-rw-r--r--spec/javascripts/sidebar/participants_spec.js14
-rw-r--r--spec/javascripts/sidebar/sidebar_subscriptions_spec.js3
-rw-r--r--spec/javascripts/sidebar/subscriptions_spec.js19
5 files changed, 124 insertions, 2 deletions
diff --git a/spec/javascripts/ide/components/repo_file_spec.js b/spec/javascripts/ide/components/repo_file_spec.js
index 4b144eef744..fbef10c90e8 100644
--- a/spec/javascripts/ide/components/repo_file_spec.js
+++ b/spec/javascripts/ide/components/repo_file_spec.js
@@ -48,6 +48,33 @@ describe('RepoFile', () => {
});
});
+ describe('folder', () => {
+ it('renders changes count inside folder', () => {
+ const f = {
+ ...file('folder'),
+ path: 'testing',
+ type: 'tree',
+ branchId: 'master',
+ projectId: 'project',
+ };
+
+ store.state.changedFiles.push({
+ ...file('fileName'),
+ path: 'testing/fileName',
+ });
+
+ createComponent({
+ file: f,
+ level: 0,
+ });
+
+ const treeChangesEl = vm.$el.querySelector('.ide-tree-changes');
+
+ expect(treeChangesEl).not.toBeNull();
+ expect(treeChangesEl.textContent).toContain('1');
+ });
+ });
+
describe('locked file', () => {
let f;
diff --git a/spec/javascripts/ide/stores/getters_spec.js b/spec/javascripts/ide/stores/getters_spec.js
index 68e0cceef76..67a848e8edd 100644
--- a/spec/javascripts/ide/stores/getters_spec.js
+++ b/spec/javascripts/ide/stores/getters_spec.js
@@ -78,4 +78,67 @@ describe('IDE store getters', () => {
expect(getters.allBlobs(localState)[0].name).toBe('blob');
});
});
+
+ describe('getChangesInFolder', () => {
+ it('returns length of changed files for a path', () => {
+ localState.changedFiles.push(
+ {
+ path: 'test/index',
+ name: 'index',
+ },
+ {
+ path: 'app/123',
+ name: '123',
+ },
+ );
+
+ expect(getters.getChangesInFolder(localState)('test')).toBe(1);
+ });
+
+ it('returns length of changed & staged files for a path', () => {
+ localState.changedFiles.push(
+ {
+ path: 'test/index',
+ name: 'index',
+ },
+ {
+ path: 'testing/123',
+ name: '123',
+ },
+ );
+
+ localState.stagedFiles.push(
+ {
+ path: 'test/123',
+ name: '123',
+ },
+ {
+ path: 'test/index',
+ name: 'index',
+ },
+ {
+ path: 'testing/12345',
+ name: '12345',
+ },
+ );
+
+ expect(getters.getChangesInFolder(localState)('test')).toBe(2);
+ });
+
+ it('returns length of changed & tempFiles files for a path', () => {
+ localState.changedFiles.push(
+ {
+ path: 'test/index',
+ name: 'index',
+ },
+ {
+ path: 'test/newfile',
+ name: 'newfile',
+ tempFile: true,
+ },
+ );
+
+ expect(getters.getChangesInFolder(localState)('test')).toBe(2);
+ });
+ });
});
diff --git a/spec/javascripts/sidebar/participants_spec.js b/spec/javascripts/sidebar/participants_spec.js
index 2a3b60c399c..e796ddee62f 100644
--- a/spec/javascripts/sidebar/participants_spec.js
+++ b/spec/javascripts/sidebar/participants_spec.js
@@ -170,5 +170,19 @@ describe('Participants', function () {
expect(vm.isShowingMoreParticipants).toBe(true);
});
+
+ it('clicking on participants icon emits `toggleSidebar` event', () => {
+ vm = mountComponent(Participants, {
+ loading: false,
+ participants: PARTICIPANT_LIST,
+ numberOfLessParticipants: 2,
+ });
+ spyOn(vm, '$emit');
+
+ const participantsIconEl = vm.$el.querySelector('.sidebar-collapsed-icon');
+
+ participantsIconEl.click();
+ expect(vm.$emit).toHaveBeenCalledWith('toggleSidebar');
+ });
});
});
diff --git a/spec/javascripts/sidebar/sidebar_subscriptions_spec.js b/spec/javascripts/sidebar/sidebar_subscriptions_spec.js
index 56a2543660b..9e437084224 100644
--- a/spec/javascripts/sidebar/sidebar_subscriptions_spec.js
+++ b/spec/javascripts/sidebar/sidebar_subscriptions_spec.js
@@ -3,7 +3,6 @@ import sidebarSubscriptions from '~/sidebar/components/subscriptions/sidebar_sub
import SidebarMediator from '~/sidebar/sidebar_mediator';
import SidebarService from '~/sidebar/services/sidebar_service';
import SidebarStore from '~/sidebar/stores/sidebar_store';
-import eventHub from '~/sidebar/event_hub';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import Mock from './mock_data';
@@ -32,7 +31,7 @@ describe('Sidebar Subscriptions', function () {
mediator,
});
- eventHub.$emit('toggleSubscription');
+ vm.onToggleSubscription();
expect(mediator.toggleSubscription).toHaveBeenCalled();
});
diff --git a/spec/javascripts/sidebar/subscriptions_spec.js b/spec/javascripts/sidebar/subscriptions_spec.js
index aee8f0acbb9..f0a53e573c3 100644
--- a/spec/javascripts/sidebar/subscriptions_spec.js
+++ b/spec/javascripts/sidebar/subscriptions_spec.js
@@ -1,5 +1,6 @@
import Vue from 'vue';
import subscriptions from '~/sidebar/components/subscriptions/subscriptions.vue';
+import eventHub from '~/sidebar/event_hub';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('Subscriptions', function () {
@@ -39,4 +40,22 @@ describe('Subscriptions', function () {
expect(vm.$refs.toggleButton.$el.querySelector('.project-feature-toggle')).toHaveClass('is-checked');
});
+
+ it('toggleSubscription method emits `toggleSubscription` event on eventHub and Component', () => {
+ vm = mountComponent(Subscriptions, { subscribed: true });
+ spyOn(eventHub, '$emit');
+ spyOn(vm, '$emit');
+
+ vm.toggleSubscription();
+ expect(eventHub.$emit).toHaveBeenCalledWith('toggleSubscription', jasmine.any(Object));
+ expect(vm.$emit).toHaveBeenCalledWith('toggleSubscription', jasmine.any(Object));
+ });
+
+ it('onClickCollapsedIcon method emits `toggleSidebar` event on component', () => {
+ vm = mountComponent(Subscriptions, { subscribed: true });
+ spyOn(vm, '$emit');
+
+ vm.onClickCollapsedIcon();
+ expect(vm.$emit).toHaveBeenCalledWith('toggleSidebar');
+ });
});