diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 21:09:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 21:09:25 +0300 |
commit | 967812838c7e7742729a4c7aeb9859f98a509622 (patch) | |
tree | 22db2e6642be51cb12535db7863331457e5523c3 /spec/frontend | |
parent | 074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 122 insertions, 0 deletions
diff --git a/spec/frontend/cycle_analytics/banner_spec.js b/spec/frontend/cycle_analytics/banner_spec.js new file mode 100644 index 00000000000..f0b8cb18a90 --- /dev/null +++ b/spec/frontend/cycle_analytics/banner_spec.js @@ -0,0 +1,45 @@ +import Vue from 'vue'; +import mountComponent from 'helpers/vue_mount_component_helper'; +import banner from '~/cycle_analytics/components/banner.vue'; + +describe('Cycle analytics banner', () => { + let vm; + + beforeEach(() => { + const Component = Vue.extend(banner); + vm = mountComponent(Component, { + documentationLink: 'path', + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('should render value stream analytics information', () => { + expect(vm.$el.querySelector('h4').textContent.trim()).toEqual( + 'Introducing Value Stream Analytics', + ); + + expect( + vm.$el + .querySelector('p') + .textContent.trim() + .replace(/[\r\n]+/g, ' '), + ).toContain( + 'Value Stream Analytics gives an overview of how much time it takes to go from idea to production in your project.', + ); + + expect(vm.$el.querySelector('a').textContent.trim()).toEqual('Read more'); + + expect(vm.$el.querySelector('a').getAttribute('href')).toEqual('path'); + }); + + it('should emit an event when close button is clicked', () => { + jest.spyOn(vm, '$emit').mockImplementation(() => {}); + + vm.$el.querySelector('.js-ca-dismiss-button').click(); + + expect(vm.$emit).toHaveBeenCalled(); + }); +}); diff --git a/spec/frontend/cycle_analytics/total_time_component_spec.js b/spec/frontend/cycle_analytics/total_time_component_spec.js new file mode 100644 index 00000000000..0f7f2628aca --- /dev/null +++ b/spec/frontend/cycle_analytics/total_time_component_spec.js @@ -0,0 +1,58 @@ +import Vue from 'vue'; +import mountComponent from 'helpers/vue_mount_component_helper'; +import component from '~/cycle_analytics/components/total_time_component.vue'; + +describe('Total time component', () => { + let vm; + let Component; + + beforeEach(() => { + Component = Vue.extend(component); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('With data', () => { + it('should render information for days and hours', () => { + vm = mountComponent(Component, { + time: { + days: 3, + hours: 4, + }, + }); + + expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('3 days 4 hrs'); + }); + + it('should render information for hours and minutes', () => { + vm = mountComponent(Component, { + time: { + hours: 4, + mins: 35, + }, + }); + + expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('4 hrs 35 mins'); + }); + + it('should render information for seconds', () => { + vm = mountComponent(Component, { + time: { + seconds: 45, + }, + }); + + expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toEqual('45 s'); + }); + }); + + describe('Without data', () => { + it('should render no information', () => { + vm = mountComponent(Component); + + expect(vm.$el.textContent.trim()).toEqual('--'); + }); + }); +}); diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js index e0b7e0bc0f3..8e6a5576015 100644 --- a/spec/frontend/diffs/components/diff_file_header_spec.js +++ b/spec/frontend/diffs/components/diff_file_header_spec.js @@ -61,6 +61,7 @@ describe('DiffFileHeader component', () => { const findTitleLink = () => wrapper.find({ ref: 'titleWrapper' }); const findExpandButton = () => wrapper.find({ ref: 'expandDiffToFullFileButton' }); const findFileActions = () => wrapper.find('.file-actions'); + const findActiveHeader = () => wrapper.find('.is-active'); const findModeChangedLine = () => wrapper.find({ ref: 'fileMode' }); const findLfsLabel = () => wrapper.find('.label-lfs'); const findToggleDiscussionsButton = () => wrapper.find({ ref: 'toggleDiscussionsButton' }); @@ -143,6 +144,11 @@ describe('DiffFileHeader component', () => { expect(wrapper.find(ClipboardButton).exists()).toBe(true); }); + it('contains a active header class if this is the active file header', () => { + createComponent({ isActive: true }); + expect(findActiveHeader().exists()).toBe(true); + }); + describe('for submodule', () => { const submoduleDiffFile = { ...diffFile, diff --git a/spec/frontend/vue_shared/components/file_row_spec.js b/spec/frontend/vue_shared/components/file_row_spec.js index b3ced84ddb5..75d1ce9cc5b 100644 --- a/spec/frontend/vue_shared/components/file_row_spec.js +++ b/spec/frontend/vue_shared/components/file_row_spec.js @@ -72,6 +72,19 @@ describe('File row component', () => { }); }); + it('is marked as viewed if clicked', () => { + createComponent({ + file: { + ...file(), + type: 'blob', + fileHash: '#123456789', + }, + level: 0, + viewedFiles: ['#123456789'], + }); + expect(wrapper.classes()).toContain('is-viewed'); + }); + it('indents row based on level', () => { createComponent({ file: file('t4'), |