fix(card): fix the bug that bodyStyle can not accept Object and Array (#754)

* fix(card): fix the bug that `bodyStyle` can not accept Object and Array

* test(card): add 'bodyStyle' test case
This commit is contained in:
Ryan2128 2020-12-01 19:57:36 +08:00 committed by GitHub
parent bd4cb60cc6
commit 20db02efe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -55,6 +55,32 @@ describe('Card.vue', () => {
expect(wrapper.find('.el-card__body').attributes('style')).toBe(style)
})
test('body style with object', () => {
const style = { 'font-size': '14px' }
const wrapper = mount(Card, {
props: {
slots: {
default: AXIOM,
},
bodyStyle: style,
},
})
expect(wrapper.find('.el-card__body').attributes('style')).toBe('font-size: 14px;')
})
test('body style with array', () => {
const style = [{ 'font-size': '14px' }, { color: 'blue' }]
const wrapper = mount(Card, {
props: {
slots: {
default: AXIOM,
},
bodyStyle: style,
},
})
expect(wrapper.find('.el-card__body').attributes('style').replace(/[ ]/g, '')).toBe('font-size:14px;color:blue;')
})
test('shadow', () => {
const shadow = 'test-shadow'
const wrapper = mount(Card, {

View File

@ -20,7 +20,7 @@ export default defineComponent({
default: '',
},
bodyStyle: {
type: String,
type: [String, Object, Array],
default: '',
},
shadow: {