diff options
Diffstat (limited to 'spec/frontend/jobs/components/log/collapsible_section_spec.js')
-rw-r--r-- | spec/frontend/jobs/components/log/collapsible_section_spec.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/frontend/jobs/components/log/collapsible_section_spec.js b/spec/frontend/jobs/components/log/collapsible_section_spec.js new file mode 100644 index 00000000000..6c1ebf0a7c1 --- /dev/null +++ b/spec/frontend/jobs/components/log/collapsible_section_spec.js @@ -0,0 +1,60 @@ +import { mount } from '@vue/test-utils'; +import CollpasibleSection from '~/jobs/components/log/collapsible_section.vue'; +import { nestedSectionOpened, nestedSectionClosed } from './mock_data'; + +describe('Job Log Collapsible Section', () => { + let wrapper; + + const traceEndpoint = 'jobs/335'; + + const findCollapsibleLine = () => wrapper.find('.collapsible-line'); + + const createComponent = (props = {}) => { + wrapper = mount(CollpasibleSection, { + sync: true, + propsData: { + ...props, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('with closed nested section', () => { + beforeEach(() => { + createComponent({ + section: nestedSectionClosed, + traceEndpoint, + }); + }); + + it('renders clickable header line', () => { + expect(findCollapsibleLine().attributes('role')).toBe('button'); + }); + }); + + describe('with opened nested section', () => { + beforeEach(() => { + createComponent({ + section: nestedSectionOpened, + traceEndpoint, + }); + }); + + it('renders all sections opened', () => { + expect(wrapper.findAll('.collapsible-line').length).toBe(2); + }); + }); + + it('emits onClickCollapsibleLine on click', () => { + createComponent({ + section: nestedSectionOpened, + traceEndpoint, + }); + + findCollapsibleLine().trigger('click'); + expect(wrapper.emitted('onClickCollapsibleLine').length).toBe(1); + }); +}); |