mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 04:08:34 +08:00
a30ae9d103
* refactor(tokens): remove tokens * Remove tokens/breadcrumb. * refactor(tokens): remove tokens/button * refactor(tokens): remove tokens/carousel * refactor(tokens): removing tokens/checkbox * refactor(tokens): removing tokens/collapse * refactor(tokens): removing tokens/dialog * refactor(tokens): removing tokens/pagination * refactor(tokens): removing tokens/radio * refactor(tokens): removing tokens/row * refactor(tokens): removing tokens/scrollbar * refactor(tokens): removing tokens/slider * refactor(tokens): removing tokens/tabs * refactor(tokens): removing tokens/upload * refactor(tokens): removing tokens/popper * refactor(tokens): removing tokens/tooltip * refactor(tokens): removing tokens/tooltip-v2 * refactor(tokens): removing tokens/date-picker * refactor(project): removing tokens/experimentals * Remove tokens/experimentals * Remove package/tokens * Remove tokens related parts * refactor(project): removing packages/tokens completely * chore: update import statement
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
import { defineComponent, provide } from 'vue'
|
|
import { NOOP } from '@vue/shared'
|
|
import { mount } from '@vue/test-utils'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { ElButton, buttonGroupContextKey } from '@element-plus/components'
|
|
import {
|
|
formContextKey,
|
|
formItemContextKey,
|
|
} from '@element-plus/components/form'
|
|
|
|
import type {
|
|
FormContext,
|
|
FormItemContext,
|
|
} from '@element-plus/components/form'
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
const mountComponent = (setup = NOOP, options = {}) =>
|
|
mount(
|
|
defineComponent({
|
|
setup,
|
|
render() {
|
|
return <ElButton {...this.$attrs}>{AXIOM}</ElButton>
|
|
},
|
|
}),
|
|
options
|
|
)
|
|
|
|
describe('use-form-item', () => {
|
|
it('should return local value', () => {
|
|
const wrapper = mountComponent()
|
|
expect(wrapper.find('.el-button').exists()).toBe(true)
|
|
})
|
|
|
|
it('should return props.size instead of injected.size', () => {
|
|
const propSize = 'small'
|
|
const wrapper = mountComponent(
|
|
() => {
|
|
provide(formItemContextKey, {
|
|
size: 'large',
|
|
} as FormItemContext)
|
|
},
|
|
{
|
|
props: { size: propSize },
|
|
}
|
|
)
|
|
|
|
expect(wrapper.find(`.el-button--${propSize}`).exists()).toBe(true)
|
|
})
|
|
|
|
it('should return fallback.size instead inject.size', () => {
|
|
const fallbackSize = 'small'
|
|
const wrapper = mountComponent(() => {
|
|
provide(buttonGroupContextKey, {
|
|
size: fallbackSize,
|
|
})
|
|
|
|
provide(formItemContextKey, {
|
|
size: 'large',
|
|
} as FormItemContext)
|
|
})
|
|
|
|
expect(wrapper.find(`.el-button--${fallbackSize}`).exists()).toBe(true)
|
|
})
|
|
|
|
it('should return formItem.size instead form.size', () => {
|
|
const itemSize = 'small'
|
|
const wrapper = mountComponent(() => {
|
|
provide(formItemContextKey, {
|
|
size: itemSize,
|
|
} as FormItemContext)
|
|
|
|
provide(formContextKey, {
|
|
size: 'large',
|
|
} as FormContext)
|
|
})
|
|
|
|
expect(wrapper.find(`.el-button--${itemSize}`).exists()).toBe(true)
|
|
})
|
|
})
|