test: fix test problem

pull/90/head
moonrailgun 2 years ago
parent 4181a426d1
commit 912c74ce72

@ -7,7 +7,7 @@ exports[`render <BBCode /> mention with space name 1`] = `
data-userid="6251986eab331ca2efbba9c6" data-userid="6251986eab331ca2efbba9c6"
> >
@ @
Notify Bot [UserName {"userId":"6251986eab331ca2efbba9c6","fallbackName":"Notify Bot"}]
</span> </span>
<pre <pre
style="display: inline; white-space: break-spaces;" style="display: inline; white-space: break-spaces;"

@ -17,12 +17,13 @@ interface UserNameProps {
* UserName, redux * UserName, redux
*/ */
export const UserNamePure: React.FC<UserNameProps> = React.memo((props) => { export const UserNamePure: React.FC<UserNameProps> = React.memo((props) => {
const { userId, showDiscriminator, className, style } = props; const { userId, showDiscriminator, className, style, fallbackName } = props;
const cachedUserInfo = useCachedUserInfo(userId); const cachedUserInfo = useCachedUserInfo(userId);
return ( return (
<span className={className} style={style}> <span className={className} style={style}>
{cachedUserInfo.nickname ?? <span>&nbsp;</span>} {cachedUserInfo.nickname ??
(isValidStr(fallbackName) ? fallbackName : <span>&nbsp;</span>)}
{showDiscriminator && ( {showDiscriminator && (
<UserNameDiscriminator discriminator={cachedUserInfo.discriminator} /> <UserNameDiscriminator discriminator={cachedUserInfo.discriminator} />

@ -0,0 +1,3 @@
export function UserName(props: any) {
return `[UserName ${JSON.stringify(props)}]`;
}

@ -4,6 +4,7 @@ jest.mock('tailchat-design/components/Icon', () => ({
Icon: ({ icon }) => `[iconify icon="${icon}"]`, Icon: ({ icon }) => `[iconify icon="${icon}"]`,
})); }));
jest.mock('../src/components/Loadable'); jest.mock('../src/components/Loadable');
jest.mock('../src/components/UserName');
const ignoreErroMessages = [ const ignoreErroMessages = [
/Warning.*not wrapped in act/, /Warning.*not wrapped in act/,

Loading…
Cancel
Save