import { defineComponent, nextTick } from 'vue' import { mount } from '@vue/test-utils' import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { provideGlobalConfig, useNamespace } from '..' import type { VueWrapper } from '@vue/test-utils' const TestComp = defineComponent({ setup() { const ns = useNamespace('table') return () => (
text
) }, }) describe('use-locale', () => { const Comp = defineComponent({ setup(_props, { slots }) { provideGlobalConfig({ namespace: 'ep' }) return () => slots.default?.() }, }) let wrapper: VueWrapper> beforeEach(() => { wrapper = mount(Comp, { slots: { default: () => }, }) }) afterEach(() => { wrapper.unmount() }) it('should provide bem correctly', async () => { await nextTick() expect(wrapper.find('#testId').classes()).toEqual([ 'ep-table', // b() 'ep-table-body', // b('body') 'ep-table__content', // e('content') 'ep-table--active', // m('active') 'ep-table-content__active', // be('content', 'active') 'ep-table__content--active', // em('content', 'active') 'ep-table-body__content--active', // bem('body', 'content', 'active') 'is-focus', // is('focus') ]) }) })