diff options
Diffstat (limited to 'spec/javascripts/vue_shared')
4 files changed, 78 insertions, 58 deletions
diff --git a/spec/javascripts/vue_shared/components/file_icon_spec.js b/spec/javascripts/vue_shared/components/file_icon_spec.js index 1c666fc6c55..f2a09d08829 100644 --- a/spec/javascripts/vue_shared/components/file_icon_spec.js +++ b/spec/javascripts/vue_shared/components/file_icon_spec.js @@ -62,9 +62,11 @@ describe('File Icon component', () => { loading: true, }); - expect( - vm.$el.querySelector('i').getAttribute('class'), - ).toEqual('fa fa-spin fa-spinner fa-1x'); + const { classList } = vm.$el.querySelector('i'); + expect(classList.contains('fa')).toEqual(true); + expect(classList.contains('fa-spin')).toEqual(true); + expect(classList.contains('fa-spinner')).toEqual(true); + expect(classList.contains('fa-1x')).toEqual(true); }); it('should add a special class and a size class', () => { diff --git a/spec/javascripts/vue_shared/components/loading_icon_spec.js b/spec/javascripts/vue_shared/components/loading_icon_spec.js deleted file mode 100644 index 5cd3466f501..00000000000 --- a/spec/javascripts/vue_shared/components/loading_icon_spec.js +++ /dev/null @@ -1,54 +0,0 @@ -import Vue from 'vue'; -import loadingIcon from '~/vue_shared/components/loading_icon.vue'; - -describe('Loading Icon Component', () => { - let LoadingIconComponent; - - beforeEach(() => { - LoadingIconComponent = Vue.extend(loadingIcon); - }); - - it('should render a spinner font awesome icon', () => { - const component = new LoadingIconComponent().$mount(); - - expect( - component.$el.querySelector('i').getAttribute('class'), - ).toEqual('fa fa-spin fa-spinner fa-1x'); - - expect(component.$el.tagName).toEqual('DIV'); - expect(component.$el.classList).toContain('text-center'); - expect(component.$el.classList).toContain('loading-container'); - }); - - it('should render accessibility attributes', () => { - const component = new LoadingIconComponent().$mount(); - - const icon = component.$el.querySelector('i'); - expect(icon.getAttribute('aria-hidden')).toEqual('true'); - expect(icon.getAttribute('aria-label')).toEqual('Loading'); - }); - - it('should render the provided label', () => { - const component = new LoadingIconComponent({ - propsData: { - label: 'This is a loading icon', - }, - }).$mount(); - - expect( - component.$el.querySelector('i').getAttribute('aria-label'), - ).toEqual('This is a loading icon'); - }); - - it('should render the provided size', () => { - const component = new LoadingIconComponent({ - propsData: { - size: '2', - }, - }).$mount(); - - expect( - component.$el.querySelector('i').classList.contains('fa-2x'), - ).toEqual(true); - }); -}); diff --git a/spec/javascripts/vue_shared/components/notes/system_note_spec.js b/spec/javascripts/vue_shared/components/notes/system_note_spec.js index 2a6015fe35f..adcb1c858aa 100644 --- a/spec/javascripts/vue_shared/components/notes/system_note_spec.js +++ b/spec/javascripts/vue_shared/components/notes/system_note_spec.js @@ -9,7 +9,7 @@ describe('system note component', () => { beforeEach(() => { props = { note: { - id: 1424, + id: '1424', author: { id: 1, name: 'Root', diff --git a/spec/javascripts/vue_shared/components/pagination_links_spec.js b/spec/javascripts/vue_shared/components/pagination_links_spec.js new file mode 100644 index 00000000000..c9d183872b4 --- /dev/null +++ b/spec/javascripts/vue_shared/components/pagination_links_spec.js @@ -0,0 +1,72 @@ +import Vue from 'vue'; +import PaginationLinks from '~/vue_shared/components/pagination_links.vue'; +import { s__ } from '~/locale'; +import mountComponent from '../../helpers/vue_mount_component_helper'; + +describe('Pagination links component', () => { + const paginationLinksComponent = Vue.extend(PaginationLinks); + const change = page => page; + const pageInfo = { + page: 3, + perPage: 5, + total: 30, + }; + const translations = { + firstText: s__('Pagination|« First'), + prevText: s__('Pagination|Prev'), + nextText: s__('Pagination|Next'), + lastText: s__('Pagination|Last »'), + }; + + let paginationLinks; + let glPagination; + let destinationComponent; + + beforeEach(() => { + paginationLinks = mountComponent( + paginationLinksComponent, + { + change, + pageInfo, + }, + ); + [glPagination] = paginationLinks.$children; + [destinationComponent] = glPagination.$children; + }); + + afterEach(() => { + paginationLinks.$destroy(); + }); + + it('should provide translated text to GitLab UI pagination', () => { + Object.entries(translations).forEach(entry => + expect( + destinationComponent[entry[0]], + ).toBe(entry[1]), + ); + }); + + it('should pass change to GitLab UI pagination', () => { + expect( + Object.is(glPagination.change, change), + ).toBe(true); + }); + + it('should pass page from pageInfo to GitLab UI pagination', () => { + expect( + destinationComponent.value, + ).toBe(pageInfo.page); + }); + + it('should pass per page from pageInfo to GitLab UI pagination', () => { + expect( + destinationComponent.perPage, + ).toBe(pageInfo.perPage); + }); + + it('should pass total items from pageInfo to GitLab UI pagination', () => { + expect( + destinationComponent.totalRows, + ).toBe(pageInfo.total); + }); +}); |