afc163
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
0 deletions
-
components/result/__tests__/index.test.tsx
-
components/result/index.tsx
|
@ -67,4 +67,11 @@ describe('Result', () => { |
|
|
|
|
|
|
|
|
warnSpy.mockRestore(); |
|
|
warnSpy.mockRestore(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should hide icon by setting icon to false or null', () => { |
|
|
|
|
|
const { container } = render(<Result title="404" icon={null} />); |
|
|
|
|
|
expect(container.querySelectorAll('.ant-result-icon')).toHaveLength(0); |
|
|
|
|
|
const { container: container2 } = render(<Result title="404" icon={false} />); |
|
|
|
|
|
expect(container2.querySelectorAll('.ant-result-icon')).toHaveLength(0); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
@ -73,10 +73,15 @@ const Icon: React.FC<IconProps> = ({ prefixCls, icon, status }) => { |
|
|
</div> |
|
|
</div> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const iconNode = React.createElement( |
|
|
const iconNode = React.createElement( |
|
|
IconMap[status as Exclude<ResultStatusType, ExceptionStatusType>], |
|
|
IconMap[status as Exclude<ResultStatusType, ExceptionStatusType>], |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (icon === null || icon === false) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return <div className={className}>{icon || iconNode}</div>; |
|
|
return <div className={className}>{icon || iconNode}</div>; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|