From f2e9e1931bab2a6f6964c0b4ec8858e7ce0cd89f Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 10 Mar 2020 20:33:11 +0800 Subject: [PATCH] fix(GoodsActionIcon): info not work with icon slot (#5788) --- src/goods-action-icon/index.js | 8 +++++++- src/goods-action-icon/index.less | 1 + .../test/__snapshots__/index.spec.js.snap | 11 ++++++++++- src/goods-action/test/index.spec.js | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/goods-action-icon/index.js b/src/goods-action-icon/index.js index 588e040e6..27c982e7e 100644 --- a/src/goods-action-icon/index.js +++ b/src/goods-action-icon/index.js @@ -1,6 +1,7 @@ import { createNamespace } from '../utils'; import { route, routeProps } from '../utils/router'; import { ChildrenMixin } from '../mixins/relation'; +import Info from '../info'; import Icon from '../icon'; const [createComponent, bem] = createNamespace('goods-action-icon'); @@ -27,7 +28,12 @@ export default createComponent({ const slot = this.slots('icon'); if (slot) { - return
{slot}
; + return ( +
+ {slot} + +
+ ); } return ( diff --git a/src/goods-action-icon/index.less b/src/goods-action-icon/index.less index 1b4f32ad2..d331e731a 100644 --- a/src/goods-action-icon/index.less +++ b/src/goods-action-icon/index.less @@ -18,6 +18,7 @@ } &__icon { + position: relative; width: 1em; margin: 0 auto 5px; color: @goods-action-icon-color; diff --git a/src/goods-action/test/__snapshots__/index.spec.js.snap b/src/goods-action/test/__snapshots__/index.spec.js.snap index fdaef8b25..1d3c01a30 100644 --- a/src/goods-action/test/__snapshots__/index.spec.js.snap +++ b/src/goods-action/test/__snapshots__/index.spec.js.snap @@ -12,6 +12,15 @@ exports[`Icon render default slot 1`] = ` exports[`Icon render icon slot 1`] = `
-
Custom Icon
Text +
Custom Icon + +
Text +
+`; + +exports[`Icon render icon slot with info 1`] = ` +
+
Custom Icon
1
+
Text
`; diff --git a/src/goods-action/test/index.spec.js b/src/goods-action/test/index.spec.js index 71f21d360..4b475e61e 100644 --- a/src/goods-action/test/index.spec.js +++ b/src/goods-action/test/index.spec.js @@ -48,3 +48,21 @@ test('Icon render icon slot', () => { expect(wrapper).toMatchSnapshot(); }); + +test('Icon render icon slot with info', () => { + const wrapper = mount({ + render(h) { + return h(Icon, { + props: { + info: '1', + }, + scopedSlots: { + default: () => 'Text', + icon: () => 'Custom Icon', + }, + }); + }, + }); + + expect(wrapper).toMatchSnapshot(); +});