feat: 重建 Bell GoAdmin 产品骨架 (#62)

This commit is contained in:
QiuSW
2026-08-27 18:20:40 +08:00
parent b37c350096
commit f5a3dd796b
715 changed files with 75278 additions and 0 deletions
@@ -0,0 +1,36 @@
import { mount } from '@vue/test-utils'
import permission from '@/directive/permission/permission'
jest.mock('@/store', () => ({
getters: {
roles: ['editor']
}
}))
// 指令通过 el.parentNode.removeChild(el) 移除元素,因此被测元素必须有父节点
const factory = value =>
mount(
{
template: '<div><section v-permission="value">内容</section></div>',
data: () => ({ value })
},
{
global: { directives: { permission } }
}
)
describe('v-permission', () => {
it('角色匹配时保留元素', () => {
const wrapper = factory(['editor'])
expect(wrapper.find('section').exists()).toBe(true)
})
it('角色不匹配时移除元素', () => {
const wrapper = factory(['admin'])
expect(wrapper.find('section').exists()).toBe(false)
})
it('角色值为空数组时抛出错误', () => {
expect(() => factory([])).toThrow('need roles!')
})
})