diff options
Diffstat (limited to 'spec/frontend/repository')
3 files changed, 53 insertions, 3 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index d462995328b..8331adcdfc2 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -375,6 +375,30 @@ describe('Blob content viewer component', () => { expect(findBlobHeader().props('isBinary')).toBe(true); }, ); + + it('passes the correct header props when viewing a non-text file', async () => { + fullFactory({ + mockData: { + blobInfo: { + ...simpleMockData, + simpleViewer: { + ...simpleMockData.simpleViewer, + fileType: 'image', + }, + }, + }, + stubs: { + BlobContent: true, + BlobReplace: true, + }, + }); + + await nextTick(); + + expect(findBlobHeader().props('hideViewerSwitcher')).toBe(true); + expect(findBlobHeader().props('isBinary')).toBe(true); + expect(findBlobEdit().props('showEditButton')).toBe(false); + }); }); describe('BlobButtonGroup', () => { diff --git a/spec/frontend/repository/components/blob_viewers/image_viewer_spec.js b/spec/frontend/repository/components/blob_viewers/image_viewer_spec.js new file mode 100644 index 00000000000..6735dddf51e --- /dev/null +++ b/spec/frontend/repository/components/blob_viewers/image_viewer_spec.js @@ -0,0 +1,25 @@ +import { shallowMount } from '@vue/test-utils'; +import ImageViewer from '~/repository/components/blob_viewers/image_viewer.vue'; + +describe('Image Viewer', () => { + let wrapper; + + const propsData = { + url: 'some/image.png', + alt: 'image.png', + }; + + const createComponent = () => { + wrapper = shallowMount(ImageViewer, { propsData }); + }; + + const findImage = () => wrapper.find('[data-testid="image"]'); + + it('renders a Source Editor component', () => { + createComponent(); + + expect(findImage().exists()).toBe(true); + expect(findImage().attributes('src')).toBe(propsData.url); + expect(findImage().attributes('alt')).toBe(propsData.alt); + }); +}); diff --git a/spec/frontend/repository/components/tree_content_spec.js b/spec/frontend/repository/components/tree_content_spec.js index 1d1ec58100f..e36287eff29 100644 --- a/spec/frontend/repository/components/tree_content_spec.js +++ b/spec/frontend/repository/components/tree_content_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import filesQuery from 'shared_queries/repository/files.query.graphql'; +import paginatedTreeQuery from 'shared_queries/repository/paginated_tree.query.graphql'; import FilePreview from '~/repository/components/preview/index.vue'; import FileTable from '~/repository/components/table/index.vue'; import TreeContent from '~/repository/components/tree_content.vue'; @@ -22,6 +22,7 @@ function factory(path, data = () => ({})) { provide: { glFeatures: { increasePageSizeExponentially: true, + paginatedTreeGraphqlQuery: true, }, }, }); @@ -58,7 +59,7 @@ describe('Repository table component', () => { it('normalizes edge nodes', () => { factory('/'); - const output = vm.vm.normalizeData('blobs', [{ node: '1' }, { node: '2' }]); + const output = vm.vm.normalizeData('blobs', { nodes: ['1', '2'] }); expect(output).toEqual(['1', '2']); }); @@ -168,7 +169,7 @@ describe('Repository table component', () => { vm.vm.fetchFiles(); expect($apollo.query).toHaveBeenCalledWith({ - query: filesQuery, + query: paginatedTreeQuery, variables: { pageSize, nextPageCursor: '', |