diff --git a/packages/card/__tests__/card.spec.ts b/packages/card/__tests__/card.spec.ts index 9efae6e1f6..03789682a6 100644 --- a/packages/card/__tests__/card.spec.ts +++ b/packages/card/__tests__/card.spec.ts @@ -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, { diff --git a/packages/card/src/index.vue b/packages/card/src/index.vue index f4f0673356..3ce2c8674c 100644 --- a/packages/card/src/index.vue +++ b/packages/card/src/index.vue @@ -20,7 +20,7 @@ export default defineComponent({ default: '', }, bodyStyle: { - type: String, + type: [String, Object, Array], default: '', }, shadow: {