Skip to content

Commit

Permalink
fix: update demo (#39366)
Browse files Browse the repository at this point in the history
* fix: update demo

* Update components/qrcode/index.tsx

Co-authored-by: MadCcc <1075746765@qq.com>

* Update index.test.tsx

Co-authored-by: MadCcc <1075746765@qq.com>
  • Loading branch information
li-jia-nan and MadCcc committed Dec 7, 2022
1 parent a836a3a commit 816cf10
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions components/qrcode/__tests__/index.test.tsx
Expand Up @@ -79,4 +79,13 @@ describe('QRCode test', () => {
'ant-qrcode-borderless',
);
});

it('should console Error when icon exist && errorLevel is `L`', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<QRCode value="test" icon="test" errorLevel="L" />);
expect(errSpy).toHaveBeenCalledWith(
'Warning: [antd: QRCode] ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.',
);
errSpy.mockRestore();
});
});
1 change: 1 addition & 0 deletions components/qrcode/demo/customSize.tsx
Expand Up @@ -36,6 +36,7 @@ const App: React.FC = () => {
</Button>
</Button.Group>
<QRCode
errorLevel="H"
size={size}
iconSize={size / 4}
value="https://ant.design/"
Expand Down
1 change: 1 addition & 0 deletions components/qrcode/demo/icon.tsx
Expand Up @@ -3,6 +3,7 @@ import { QRCode } from 'antd';

const App: React.FC = () => (
<QRCode
errorLevel="H"
value="https://ant.design/"
icon="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
/>
Expand Down
8 changes: 8 additions & 0 deletions components/qrcode/index.tsx
Expand Up @@ -59,6 +59,14 @@ const QRCode: React.FC<QRCodeProps> = (props) => {
return null;
}

if (process.env.NODE_ENV !== 'production') {
warning(
!(icon && errorLevel === 'L'),
'QRCode',
'ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.',
);
}

const cls = classNames(prefixCls, className, hashId, {
[`${prefixCls}-borderless`]: !bordered,
});
Expand Down
1 change: 0 additions & 1 deletion components/qrcode/interface.ts
Expand Up @@ -12,7 +12,6 @@ interface ImageSettings {
interface QRProps {
value: string;
size?: number;
level?: string;
color?: string;
style?: CSSProperties;
includeMargin?: boolean;
Expand Down

0 comments on commit 816cf10

Please sign in to comment.