test(components): [button] add test cases for using props of form and form-item (#13726)

test(components): add test cases for using props of form and form-item

add case for using size and disabled from form

add case for using size from form-item
This commit is contained in:
Fl 2023-07-29 22:18:45 +08:00 committed by GitHub
parent 93b230166c
commit 4515023c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { mount } from '@vue/test-utils'
import { describe, expect, it, test } from 'vitest'
import { Loading, Search } from '@element-plus/icons-vue'
import Form from '@element-plus/components/form'
import Button from '../src/button.vue'
import ButtonGroup from '../src/button-group.vue'
import type { ComponentSize } from '@element-plus/constants'
@ -259,4 +260,35 @@ describe('Button Group', () => {
'el-button__text--expand'
)
})
it('shoule use props of form', async () => {
const wrapper = mount({
setup: () => () =>
(
<Form size="large" disabled>
<Button>{{ AXIOM }}</Button>
</Form>
),
})
const btn = wrapper.findComponent(Button)
expect(btn.classes()).toContain('el-button--large')
expect(btn.classes()).toContain('is-disabled')
await btn.trigger('click')
expect(btn.emitted('click')).toBeUndefined()
})
it('shoule use size of form-item', async () => {
const wrapper = mount({
setup: () => () =>
(
<Form size="large" disabled>
<Form.FormItem size="small">
<Button>{{ AXIOM }}</Button>
</Form.FormItem>
</Form>
),
})
const btn = wrapper.findComponent(Button)
expect(btn.classes()).toContain('el-button--small')
})
})