import{ describe, it, expect }from'vitest'import{ mount }from'@vue/test-utils'import Button from'./Button.vue'describe('Button.vue',()=>{// Props: typeit('should has the correct type class when type prop is set',()=>{const types =['primary','success','warning','danger','info']
types.forEach((type)=>{const wrapper =mount(Button,{
props:{ type:typeasany},})expect(wrapper.classes()).toContain(`er-button--${type}`)})})// Props: sizeit('should has the correct size class when size prop is set',()=>{const sizes =['large','default','small']
sizes.forEach((size)=>{const wrapper =mount(Button,{
props:{ size: size asany},})expect(wrapper.classes()).toContain(`er-button--${size}`)})})// Props: plain, round, circle
it.each([['plain','is-plain'],['round','is-round'],['circle','is-circle'],['disabled','is-disabled'],['loading','is-loading'],])('should has the correct class when prop %s is set to true',(prop, className)=>{const wrapper =mount(Button,{
props:{[prop]:true},
global:{
stubs:['ErIcon'],},})expect(wrapper.classes()).toContain(className)})it('should has the correct native type attribute when native-type prop is set',()=>{const wrapper =mount(Button,{
props:{ nativeType:'submit'},})expect(wrapper.element.tagName).toBe('BUTTON')expect((wrapper.element asany).type).toBe('submit')})// Props: tagit('should renders the custom tag when tag prop is set',()=>{const wrapper =mount(Button,{
props:{ tag:'a'},})expect(wrapper.element.tagName.toLowerCase()).toBe('a')})// Events: clickit('should emits a click event when the button is clicked',async()=>{const wrapper =mount(Button,{})await wrapper.trigger('click')expect(wrapper.emitted().click).toHaveLength(1)})})