diff options
Diffstat (limited to 'spec/frontend/blob/components')
-rw-r--r-- | spec/frontend/blob/components/blob_header_default_actions_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/blob/components/blob_header_spec.js | 12 |
2 files changed, 21 insertions, 3 deletions
diff --git a/spec/frontend/blob/components/blob_header_default_actions_spec.js b/spec/frontend/blob/components/blob_header_default_actions_spec.js index bce65899c43..e321bb41774 100644 --- a/spec/frontend/blob/components/blob_header_default_actions_spec.js +++ b/spec/frontend/blob/components/blob_header_default_actions_spec.js @@ -39,6 +39,9 @@ describe('Blob Header Default Actions', () => { }); describe('renders', () => { + const findCopyButton = () => wrapper.find('[data-testid="copyContentsButton"]'); + const findViewRawButton = () => wrapper.find('[data-testid="viewRawButton"]'); + it('gl-button-group component', () => { expect(btnGroup.exists()).toBe(true); }); @@ -76,7 +79,14 @@ describe('Blob Header Default Actions', () => { hasRenderError: true, }); - expect(wrapper.find('[data-testid="copyContentsButton"]').exists()).toBe(false); + expect(findCopyButton().exists()).toBe(false); + }); + + it('does not render the copy and view raw button if isBinary is set to true', () => { + createComponent({ isBinary: true }); + + expect(findCopyButton().exists()).toBe(false); + expect(findViewRawButton().exists()).toBe(false); }); }); }); diff --git a/spec/frontend/blob/components/blob_header_spec.js b/spec/frontend/blob/components/blob_header_spec.js index 865e8ab1124..f841785be42 100644 --- a/spec/frontend/blob/components/blob_header_spec.js +++ b/spec/frontend/blob/components/blob_header_spec.js @@ -29,6 +29,8 @@ describe('Blob Header Default Actions', () => { }); describe('rendering', () => { + const findDefaultActions = () => wrapper.find(DefaultActions); + const slots = { prepend: 'Foo Prepend', actions: 'Actions Bar', @@ -42,7 +44,7 @@ describe('Blob Header Default Actions', () => { it('renders all components', () => { createComponent(); expect(wrapper.find(ViewerSwitcher).exists()).toBe(true); - expect(wrapper.find(DefaultActions).exists()).toBe(true); + expect(findDefaultActions().exists()).toBe(true); expect(wrapper.find(BlobFilepath).exists()).toBe(true); }); @@ -100,7 +102,13 @@ describe('Blob Header Default Actions', () => { hasRenderError: true, }, ); - expect(wrapper.find(DefaultActions).props('hasRenderError')).toBe(true); + expect(findDefaultActions().props('hasRenderError')).toBe(true); + }); + + it('passes the correct isBinary value to default actions when viewing a binary file', () => { + createComponent({}, {}, { isBinary: true }); + + expect(findDefaultActions().props('isBinary')).toBe(true); }); }); |