diff options
author | Phil Hughes <me@iamphill.com> | 2018-05-04 14:00:22 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-05-04 14:00:22 +0100 |
commit | 14b8ac3e2a1c29c7f86391118f6916959a1337c6 (patch) | |
tree | 3e6f89e5dc2cb6e33c281fbae32ebe4e52d1968d /spec/javascripts | |
parent | aeb4b7508fabb36388c904a6e7d7d6c21f951961 (diff) | |
parent | 805302c0c09f0c6a3226efd2d3fca1b46015f9e0 (diff) | |
download | gitlab-ce-14b8ac3e2a1c29c7f86391118f6916959a1337c6.tar.gz |
Merge branch '44846-improve-web-ide-left-panel-and-modes' into ide-sidebar-merge-request
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/ide/components/repo_file_spec.js | 65 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/getters_spec.js | 63 | ||||
-rw-r--r-- | spec/javascripts/sidebar/participants_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/sidebar/sidebar_subscriptions_spec.js | 3 | ||||
-rw-r--r-- | spec/javascripts/sidebar/subscriptions_spec.js | 19 |
5 files changed, 142 insertions, 22 deletions
diff --git a/spec/javascripts/ide/components/repo_file_spec.js b/spec/javascripts/ide/components/repo_file_spec.js index 4b144eef744..156233653ab 100644 --- a/spec/javascripts/ide/components/repo_file_spec.js +++ b/spec/javascripts/ide/components/repo_file_spec.js @@ -48,36 +48,32 @@ describe('RepoFile', () => { }); }); - describe('locked file', () => { - let f; - - beforeEach(() => { - f = file('locked file'); - f.file_lock = { - user: { - name: 'testuser', - updated_at: new Date(), - }, + 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, }); - }); - it('renders lock icon', () => { - expect(vm.$el.querySelector('.file-status-icon')).not.toBeNull(); - }); + const treeChangesEl = vm.$el.querySelector('.ide-tree-changes'); - it('renders a tooltip', () => { - expect( - vm.$el.querySelector('.ide-file-name span:nth-child(2)').dataset.originalTitle, - ).toContain('Locked by testuser'); + expect(treeChangesEl).not.toBeNull(); + expect(treeChangesEl.textContent).toContain('1'); }); - }); - describe('folder', () => { it('renders action dropdown', done => { createComponent({ file: { @@ -115,4 +111,33 @@ describe('RepoFile', () => { }); }); }); + + describe('locked file', () => { + let f; + + beforeEach(() => { + f = file('locked file'); + f.file_lock = { + user: { + name: 'testuser', + updated_at: new Date(), + }, + }; + + createComponent({ + file: f, + level: 0, + }); + }); + + it('renders lock icon', () => { + expect(vm.$el.querySelector('.file-status-icon')).not.toBeNull(); + }); + + it('renders a tooltip', () => { + expect( + vm.$el.querySelector('.ide-file-name span:nth-child(2)').dataset.originalTitle, + ).toContain('Locked by testuser'); + }); + }); }); 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'); + }); }); |