Skip to content

Commit

Permalink
fix: extraCommonProps not work properly (#19572)
Browse files Browse the repository at this point in the history
* fix extraCommonProps not work properly

* add test case
  • Loading branch information
yoyo837 authored and afc163 committed Nov 5, 2019
1 parent 8cff912 commit e150cfc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/icon/IconFont.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function create(options: CustomIconOptions = {}): React.SFC<IconP
content = children;
}
return (
<Icon {...restProps} {...extraCommonProps}>
<Icon {...extraCommonProps} {...restProps}>
{content}
</Icon>
);
Expand Down
61 changes: 58 additions & 3 deletions components/icon/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,67 @@ exports[`Icon support render svg as component 1`] = `
</i>
`;

exports[`Icon.createFromIconfontCN() extraCommonProps should works fine and can be overwritten 1`] = `
<div
class="icons-list"
>
<i
class="anticon bcd"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-tuichu"
/>
</svg>
</i>
<i
class="anticon abc"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-facebook"
/>
</svg>
</i>
<i
class="anticon efg"
>
<svg
aria-hidden="true"
class=""
fill="currentColor"
focusable="false"
height="1em"
width="1em"
>
<use
href="#icon-twitter"
/>
</svg>
</i>
</div>
`;

exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
<div
class="icons-list"
>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand All @@ -391,7 +446,7 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand All @@ -407,7 +462,7 @@ exports[`Icon.createFromIconfontCN() should support iconfont.cn 1`] = `
</svg>
</i>
<i
class="anticon"
class="anticon abc"
>
<svg
aria-hidden="true"
Expand Down
14 changes: 14 additions & 0 deletions components/icon/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ describe('Icon', () => {
describe('Icon.createFromIconfontCN()', () => {
const IconFont = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js',
extraCommonProps: {
className: 'abc',
},
});

it('should support iconfont.cn', () => {
Expand All @@ -192,6 +195,17 @@ describe('Icon.createFromIconfontCN()', () => {
);
expect(wrapper).toMatchSnapshot();
});

it('extraCommonProps should works fine and can be overwritten', () => {
const wrapper = render(
<div className="icons-list">
<IconFont type="icon-tuichu" className="bcd" />
<IconFont type="icon-facebook" />
<IconFont type="icon-twitter" className="efg" />
</div>,
);
expect(wrapper).toMatchSnapshot();
});
});

describe('utils', () => {
Expand Down

0 comments on commit e150cfc

Please sign in to comment.