('.ant-qrcode canvas')).toHaveStyle(
'width: 100%; height: 80%;',
);
});
it('custom status render', () => {
const refreshCb = jest.fn();
const customStatusRender: QRCodeProps['statusRender'] = (info) => {
switch (info.status) {
case 'expired':
return (
{info.locale?.expired}
);
case 'loading':
return Loading
;
case 'scanned':
return {info.locale?.scanned}
;
default:
return null;
}
};
const { container } = render(
<>
>,
);
expect(
container.querySelector('.qrcode-expired .custom-expired>span')?.textContent,
).toBe('QR code expired');
fireEvent.click(container?.querySelector('#refresh')!);
expect(refreshCb).toHaveBeenCalled();
expect(
container.querySelector('.qrcode-loading .custom-loading')?.textContent,
).toBe('Loading');
expect(
container.querySelector('.qrcode-scanned .custom-scanned')?.textContent,
).toBe('Scanned');
expect(container).toMatchSnapshot();
});
});