import { GlIcon, GlButton, GlIntersectionObserver } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import IssuableTitle from '~/issuable_show/components/issuable_title.vue'; import { mockIssuableShowProps, mockIssuable } from '../mock_data'; const issuableTitleProps = { issuable: mockIssuable, ...mockIssuableShowProps, }; const createComponent = (propsData = issuableTitleProps) => shallowMount(IssuableTitle, { propsData, stubs: { transition: true, }, slots: { 'status-badge': 'Open', }, directives: { GlTooltip: createMockDirective(), }, }); describe('IssuableTitle', () => { let wrapper; beforeEach(() => { wrapper = createComponent(); }); afterEach(() => { wrapper.destroy(); }); describe('methods', () => { describe('handleTitleAppear', () => { it('sets value of `stickyTitleVisible` prop to false', () => { wrapper.find(GlIntersectionObserver).vm.$emit('appear'); expect(wrapper.vm.stickyTitleVisible).toBe(false); }); }); describe('handleTitleDisappear', () => { it('sets value of `stickyTitleVisible` prop to true', () => { wrapper.find(GlIntersectionObserver).vm.$emit('disappear'); expect(wrapper.vm.stickyTitleVisible).toBe(true); }); }); }); describe('template', () => { it('renders issuable title', async () => { const wrapperWithTitle = createComponent({ ...mockIssuableShowProps, issuable: { ...mockIssuable, titleHtml: 'Sample title', }, }); await wrapperWithTitle.vm.$nextTick(); const titleEl = wrapperWithTitle.find('h2'); expect(titleEl.exists()).toBe(true); expect(titleEl.html()).toBe('