From 185999615962bd09dc410997a813ebe981a6f01e Mon Sep 17 00:00:00 2001 From: Paul Slaughter Date: Wed, 12 Jun 2019 15:58:48 +0000 Subject: Extract ide_status_list from ide_status_bar **Why?** The ide_status_list will be used and extended in EE. --- app/assets/javascripts/ide/components/ide.vue | 2 +- .../javascripts/ide/components/ide_status_bar.vue | 16 +--- .../javascripts/ide/components/ide_status_list.vue | 23 ++++++ app/assets/stylesheets/page_bundles/ide.scss | 15 ++-- .../ide/components/ide_status_list_spec.js | 91 ++++++++++++++++++++++ 5 files changed, 124 insertions(+), 23 deletions(-) create mode 100644 app/assets/javascripts/ide/components/ide_status_list.vue create mode 100644 spec/frontend/ide/components/ide_status_list_spec.js diff --git a/app/assets/javascripts/ide/components/ide.vue b/app/assets/javascripts/ide/components/ide.vue index e41b1530226..363a8f43033 100644 --- a/app/assets/javascripts/ide/components/ide.vue +++ b/app/assets/javascripts/ide/components/ide.vue @@ -146,7 +146,7 @@ export default { - + diff --git a/app/assets/javascripts/ide/components/ide_status_bar.vue b/app/assets/javascripts/ide/components/ide_status_bar.vue index ce577ae85b0..206b8341aad 100644 --- a/app/assets/javascripts/ide/components/ide_status_bar.vue +++ b/app/assets/javascripts/ide/components/ide_status_bar.vue @@ -1,5 +1,6 @@ + + diff --git a/app/assets/stylesheets/page_bundles/ide.scss b/app/assets/stylesheets/page_bundles/ide.scss index f08fa80495d..cbcd8a474f1 100644 --- a/app/assets/stylesheets/page_bundles/ide.scss +++ b/app/assets/stylesheets/page_bundles/ide.scss @@ -396,10 +396,6 @@ $ide-commit-header-height: 48px; font-size: inherit; } - > div + div { - padding-left: $gl-padding; - } - svg { vertical-align: sub; } @@ -410,13 +406,14 @@ $ide-commit-header-height: 48px; } } +.ide-status-list { + > div + div { + padding-left: $gl-padding; + } +} + .ide-status-file { text-align: right; - - .ide-status-branch + &, - &:first-child { - margin-left: auto; - } } // Not great, but this is to deal with our current output .multi-file-preview-holder { diff --git a/spec/frontend/ide/components/ide_status_list_spec.js b/spec/frontend/ide/components/ide_status_list_spec.js new file mode 100644 index 00000000000..4e0e8a9f0e3 --- /dev/null +++ b/spec/frontend/ide/components/ide_status_list_spec.js @@ -0,0 +1,91 @@ +import Vuex from 'vuex'; +import { createLocalVue, shallowMount } from '@vue/test-utils'; +import IdeStatusList from '~/ide/components/ide_status_list'; + +const TEST_FILE = { + name: 'lorem.md', + eol: 'LF', + editorRow: 3, + editorColumn: 23, + fileLanguage: 'markdown', +}; + +const localVue = createLocalVue(); +localVue.use(Vuex); + +describe('ide/components/ide_status_list', () => { + let activeFile; + let store; + let wrapper; + + const createComponent = (options = {}) => { + store = new Vuex.Store({ + getters: { + activeFile: () => activeFile, + }, + }); + + wrapper = shallowMount(localVue.extend(IdeStatusList), { + localVue, + sync: false, + store, + ...options, + }); + }; + + beforeEach(() => { + activeFile = TEST_FILE; + }); + + afterEach(() => { + wrapper.destroy(); + + store = null; + wrapper = null; + }); + + const getEditorPosition = file => `${file.editorRow}:${file.editorColumn}`; + + describe('with regular file', () => { + beforeEach(() => { + createComponent(); + }); + + it('shows file name', () => { + expect(wrapper.text()).toContain(TEST_FILE.name); + }); + + it('shows file eol', () => { + expect(wrapper.text()).toContain(TEST_FILE.name); + }); + + it('shows file editor position', () => { + expect(wrapper.text()).toContain(getEditorPosition(TEST_FILE)); + }); + + it('shows file language', () => { + expect(wrapper.text()).toContain(TEST_FILE.fileLanguage); + }); + }); + + describe('with binary file', () => { + beforeEach(() => { + activeFile.binary = true; + createComponent(); + }); + + it('does not show file editor position', () => { + expect(wrapper.text()).not.toContain(getEditorPosition(TEST_FILE)); + }); + }); + + it('adds slot as child of list', () => { + createComponent({ + slots: { + default: ['
Hello
', '
World
'], + }, + }); + + expect(wrapper.find('.ide-status-list').findAll('.js-test').length).toEqual(2); + }); +}); -- cgit v1.2.1