diff --git a/packages/components/card/__tests__/card.spec.ts b/packages/components/card/__tests__/card.spec.tsx
similarity index 55%
rename from packages/components/card/__tests__/card.spec.ts
rename to packages/components/card/__tests__/card.spec.tsx
index 872380a268..0a270e27ba 100644
--- a/packages/components/card/__tests__/card.spec.ts
+++ b/packages/components/card/__tests__/card.spec.tsx
@@ -5,66 +5,46 @@ const AXIOM = 'Rem is the best girl'
describe('Card.vue', () => {
test('render test', () => {
- const wrapper = mount(Card, {
- slots: {
- default: AXIOM,
- },
- })
+ const wrapper = mount(() => {AXIOM})
+
expect(wrapper.text()).toEqual(AXIOM)
})
test('string header', () => {
const header = 'I am header'
- const wrapper = mount(Card, {
- slots: {
- default: AXIOM,
- },
- props: {
- header,
- },
- })
+ const wrapper = mount(() => {AXIOM})
expect(wrapper.text()).toContain(header)
})
test('vnode header', () => {
const headerCls = 'header-text'
const btnCls = 'test-btn'
- const wrapper = mount(Card, {
- slots: {
- default: AXIOM,
- header: `
-
-
-
`,
- },
- })
+ const wrapper = mount(() => (
+ AXIOM,
+ header: () => (
+
+
+
+
+ ),
+ }}
+ />
+ ))
expect(wrapper.find('.header-text').exists()).toBe(true)
expect(wrapper.find('.test-btn').exists()).toBe(true)
})
test('body style', () => {
const style = 'font-size: 14px;'
- const wrapper = mount(Card, {
- props: {
- slots: {
- default: AXIOM,
- },
- bodyStyle: style,
- },
- })
+ const wrapper = mount(() => {AXIOM})
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,
- },
- })
+ const wrapper = mount(() => {AXIOM})
expect(wrapper.find('.el-card__body').attributes('style')).toBe(
'font-size: 14px;'
)
@@ -72,14 +52,7 @@ describe('Card.vue', () => {
test('body style with array', () => {
const style = [{ 'font-size': '14px' }, { color: 'blue' }]
- const wrapper = mount(Card, {
- props: {
- slots: {
- default: AXIOM,
- },
- bodyStyle: style,
- },
- })
+ const wrapper = mount(() => {AXIOM})
expect(
wrapper.find('.el-card__body').attributes('style').replace(/[ ]/g, '')
).toBe('font-size:14px;color:blue;')
@@ -87,14 +60,7 @@ describe('Card.vue', () => {
test('shadow', () => {
const shadow = 'test-shadow'
- const wrapper = mount(Card, {
- props: {
- slots: {
- default: AXIOM,
- },
- shadow,
- },
- })
+ const wrapper = mount(() => {AXIOM})
expect(wrapper.find(`.is-${shadow}-shadow`).exists()).toBe(true)
})
diff --git a/packages/components/card/src/card.vue b/packages/components/card/src/card.vue
index 6977b82a12..6e74045eef 100644
--- a/packages/components/card/src/card.vue
+++ b/packages/components/card/src/card.vue
@@ -8,20 +8,15 @@
-