mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
test(client): stabilize UI regression tests
Replace brittle client snapshot coverage with explicit assertions so the updated test stack no longer depends on snapshot state initialization. Update the react-i18next mock to avoid mutating function component defaultProps while preserving WrappedComponent metadata for layout tests.
This commit is contained in:
Vendored
+10
-2
@@ -35,8 +35,16 @@ const renderNodes = reactNodes => {
|
||||
};
|
||||
|
||||
const withTranslation = () => Component => {
|
||||
Component.defaultProps = { ...Component.defaultProps, t: str => str };
|
||||
return Component;
|
||||
const WrappedComponent = props =>
|
||||
React.createElement(Component, {
|
||||
...props,
|
||||
t: props.t ?? (str => str)
|
||||
});
|
||||
|
||||
WrappedComponent.WrappedComponent = Component;
|
||||
WrappedComponent.displayName = `withTranslation(${Component.displayName || Component.name || 'Component'})`;
|
||||
|
||||
return WrappedComponent;
|
||||
};
|
||||
|
||||
const useTranslation = () => {
|
||||
|
||||
Reference in New Issue
Block a user