Skip to content

Commit 0067ec4

Browse files
fix: test
Signed-off-by: Joris Mancini <[email protected]>.com> Signed-off-by: Joris Mancini <[email protected]>
1 parent ee0f395 commit 0067ec4

File tree

7 files changed

+23
-10
lines changed

7 files changed

+23
-10
lines changed

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { Config } from 'jest';
1010
const config: Config = {
1111
testEnvironment: 'jsdom',
1212
moduleNameMapper: {
13-
'^.+\\.svg\\?react$': 'jest-svg-transformer',
13+
'^.+\\.svg\\?react$': '<rootDir>/src/_mocks_/svg.tsx',
1414
'^.+\\.(css|less|scss)$': 'identity-obj-proxy',
1515
},
1616
// see https://github.com/react-dnd/react-dnd/issues/3443

src/_mocks_/fetch.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
export default function fetchMock() {
9+
return Promise.resolve({
10+
ok: true,
11+
json: () => ({ appsMetadataServerUrl: '' }), // just to remove the error logs when fetching env
12+
});
13+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*
1+
/**
22
* Copyright (c) 2024, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import AppComponent from './App';
8+
import { forwardRef, SVGProps } from 'react';
99

10-
export type App = typeof AppComponent;
10+
const SvgrMock = forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>((props, ref) => <svg ref={ref} {...props} />);
1111

12-
export { AppWrapper } from './AppWrapper';
12+
export default SvgrMock;

src/components/App/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { selectComputedLanguage, selectLanguage, selectTheme } from '../../redux
2626
import { AppState } from '../../redux/reducer';
2727
import { AppsMetadataSrv, ConfigParameters } from '../../services';
2828
import { APP_NAME, COMMON_APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../../utils/config-params';
29-
import { AppTopBar } from './AppTopBar';
29+
import AppTopBar from './AppTopBar';
3030
import { useDebugRender } from '../../utils/hooks';
3131
import { AppDispatch } from '../../redux/store';
3232
import { Navigate, Route, Routes, useLocation, useMatch, useNavigate } from 'react-router';

src/components/App/AppTopBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type AppTopBarProps = {
8585
userManagerInstance: UserManagerState['instance'];
8686
};
8787

88-
export function AppTopBar({ userManagerInstance }: Readonly<AppTopBarProps>) {
88+
export default function AppTopBar({ userManagerInstance }: Readonly<AppTopBarProps>) {
8989
const theme = useTheme();
9090
const dispatch = useDispatch<AppDispatch>();
9191
const user = useSelector((state: AppState) => state.user);

src/components/App/AppWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ const AppWrapperWithRedux = () => {
177177
);
178178
};
179179

180-
export const AppWrapper = () => {
180+
export default function AppWrapper() {
181181
return (
182182
<Provider store={store}>
183183
<AppWrapperWithRedux />
184184
</Provider>
185185
);
186-
};
186+
}

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'typeface-roboto';
1010
import React from 'react';
1111
import { createRoot } from 'react-dom/client';
1212
import './index.css';
13-
import { AppWrapper } from './components/App';
13+
import AppWrapper from './components/App/AppWrapper';
1414

1515
const container = document.getElementById('root');
1616
if (container) {

0 commit comments

Comments
 (0)