<commit_before>import { shallow } from '@vue/test-utils'
import BSlotComponent from '@utils/SlotComponent'
import Vue from 'vue'

describe('BSlotComponent', () => {
    it('is called', () => {
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: {}
            }
        })

        expect(wrapper.name()).toBe('BSlotComponent')
        expect(wrapper.isVueInstance()).toBeTruthy()
    })

    it('default render', () => {
        const slot = 'Content'
        const component = shallow(Vue, {
            slots: {
                default: slot
            }
        })
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: component.vm
            }
        })
        expect(wrapper.html()).toBe(`<div>${slot}</div>`)
    })

    it('render', () => {
        const slot = 'Content'
        const slotName = 'header'
        const component = shallow(Vue, {
            slots: {
                [slotName]: slot
            }
        })
        const tag = 'span'
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: component.vm,
                tag: tag,
                name: slotName
            }
        })
        expect(wrapper.html()).toBe(`<${tag}>${slot}</${tag}>`)
    })
})<commit_msg>Update SlotComponent test<commit_after>import { shallow } from '@vue/test-utils'
import BSlotComponent from '@utils/SlotComponent'

describe('BSlotComponent', () => {
    const MockComponent = {
        render: (h) => h('div', {}, 'Hello!')
    }
    it('is called', () => {
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: {}
            }
        })

        expect(wrapper.name()).toBe('BSlotComponent')
        expect(wrapper.isVueInstance()).toBeTruthy()
    })

    it('default render', () => {
        const slot = '<span>Content</span>'
        const Component = shallow(MockComponent, {
            slots: {
                default: slot
            }
        })
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: Component.vm
            }
        })
        expect(wrapper.html()).toBe(`<div>${slot}</div>`)
    })

    it('render', () => {
        const slot = '<span>Content</span>'
        const slotName = 'header'
        const Component = shallow(MockComponent, {
            slots: {
                [slotName]: slot
            }
        })
        const tag = 'span'
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: Component.vm,
                tag: tag,
                name: slotName
            }
        })
        expect(wrapper.html()).toBe(`<${tag}>${slot}</${tag}>`)
    })

    it('render after emit event', async () => {
        const slot = '<span>Content</span>'
        const Component = shallow(MockComponent, {
            slots: {
                default: slot
            }
        })
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: Component.vm
            }
        })
        Component.vm.$emit('updated', {})
        await wrapper.vm.$nextTick()
        expect(wrapper.html()).toBe(`<div>${slot}</div>`)
    })

    it('refresh', () => {
        const event = 'component-event'
        const slot = '<span>Content</span>'
        const Component = shallow(MockComponent, {
            slots: {
                default: slot
            }
        })
        const refresh = jest.fn()
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: Component.vm,
                event
            },
            methods: {
                refresh
            }
        })
        Component.vm.$emit(event, {})
        expect(refresh).toHaveBeenCalledTimes(1)
        expect(wrapper.html()).toBe(`<div>${slot}</div>`)
    })

    it('destroy', () => {
        const slot = '<span>Content</span>'
        const Component = shallow(MockComponent, {
            slots: {
                default: slot
            }
        })
        const refresh = jest.fn()
        const wrapper = shallow(BSlotComponent, {
            propsData: {
                component: Component.vm
            },
            methods: {
                refresh
            }
        })
        wrapper.destroy()
        Component.vm.$emit('updated', {})
        expect(refresh).toHaveBeenCalledTimes(0)
    })
})
{'fraction_non_alphanumeric': 0.14029652578003984, 'fraction_numerical': 0.0004425757911042266, 'mean_word_length': 1.469945355191257, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3287573', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1171, 'n_words': 214}