Skip to content

Commit e1b3f22

Browse files
committed
fix(ga): issue #606 - update unit test and code
1 parent b83cc1a commit e1b3f22

14 files changed

+40
-29
lines changed

packages/webapp/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
'.+\\.(css|sass|scss)$': 'jest-css-modules-transform'
2727
},
2828
moduleNameMapper: {
29-
'.+\\.(svg)$': '<rootDir>/test/__mocks__/svgMock.ts',
29+
'.+\\.(svg)$': '<rootDir>/test/__mocks__/svg.mock.ts',
3030
uuid: require.resolve('uuid')
3131
},
3232
transformIgnorePatterns: ['<rootDir>/node_modules/'],

packages/webapp/test/App.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { initI18n } from '../src/webview/i18n';
66
import { Provider } from 'react-redux';
77
import configureMockStore from 'redux-mock-store';
88
import { getInitialState, reducer } from '../src/webview/state/reducers';
9-
import { treeMock } from './__mocks__/treeMock';
9+
import { treeMock } from './__mocks__/tree.mock';
1010

1111
jest.mock('../src/webview/state', () => {
1212
return {

packages/webapp/test/FeedbackSection/FeedbackSection.test.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ import configureMockStore from 'redux-mock-store';
88
import { getInitialState, reducer } from '../../src/webview/state/reducers';
99
import { AppState } from '../../src/webview/types';
1010
import { useSelector } from 'react-redux';
11-
import { treeMock } from '../__mocks__/treeMock';
11+
import { treeMock } from '../__mocks__/tree.mock';
1212

1313
const initialState = {
1414
...getInitialState(),
1515
activeGuidedAnswer: treeMock,
16-
activeGuidedAnswerNode: [{
17-
BODY: '<p>SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code</p>',
18-
EDGES: [
19-
{ LABEL: 'Deployment', TARGET_NODE: 45996, ORD: 1 },
20-
{ LABEL: 'Fiori Generator', TARGET_NODE: 48363, ORD: 2 }
21-
],
22-
NODE_ID: 45995,
23-
QUESTION: 'I have a problem with',
24-
TITLE: 'SAP Fiori Tools'
25-
}]
16+
activeGuidedAnswerNode: [
17+
{
18+
BODY: '<p>SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code</p>',
19+
EDGES: [
20+
{ LABEL: 'Deployment', TARGET_NODE: 45996, ORD: 1 },
21+
{ LABEL: 'Fiori Generator', TARGET_NODE: 48363, ORD: 2 }
22+
],
23+
NODE_ID: 45995,
24+
QUESTION: 'I have a problem with',
25+
TITLE: 'SAP Fiori Tools'
26+
}
27+
]
2628
};
2729

2830
jest.mock('../../src/webview/state', () => {

packages/webapp/test/GuidedAnswerNode/Middle.test.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { treeMock } from '../__mocks__/treeMock';
21
import React, { ReactElement } from 'react';
32
import { useSelector } from 'react-redux';
43
import { render, fireEvent, cleanup } from '@testing-library/react';
54
import { screen } from '@testing-library/dom';
5+
66
import { Middle } from '../../src/webview/ui/components/GuidedAnswerNode/Middle';
77
import { actions } from '../../src/webview/state';
88
import { initI18n } from '../../src/webview/i18n';
99

10+
import { treeMock } from '../__mocks__/tree.mock';
11+
1012
let activeNodeMock = {
1113
BODY: '<p>SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code</p>',
1214
EDGES: [

packages/webapp/test/Header/Filters.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { treeMock } from '../__mocks__/treeMock';
21
import React from 'react';
32
import { render, fireEvent, cleanup } from '@testing-library/react';
43
import { initI18n } from '../../src/webview/i18n';
@@ -13,6 +12,8 @@ import {
1312
sortComponentFilters
1413
} from '../../src/webview/ui/components/Header/Filters/Filters';
1514

15+
import { treeMock } from '../__mocks__/tree.mock';
16+
1617
const createState = (initialState: AppState) => (actions: any[]) => actions.reduce(reducer, initialState);
1718
const mockStore = configureMockStore();
1819

packages/webapp/test/Header/FiltersRibbon.test.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react';
2+
import { Provider } from 'react-redux';
3+
import configureMockStore from 'redux-mock-store';
4+
import { screen } from '@testing-library/dom';
25
import { render, fireEvent, cleanup } from '@testing-library/react';
6+
37
import { initI18n } from '../../src/webview/i18n';
48
import { FiltersRibbon } from '../../src/webview/ui/components/Header/Filters/FiltersRibbon';
59
import { actions } from '../../src/webview/state';
6-
import { Provider } from 'react-redux';
710
import { getInitialState, reducer } from '../../src/webview/state/reducers';
811
import { AppState } from '../../src/webview/types';
9-
import configureMockStore from 'redux-mock-store';
10-
import { screen } from '@testing-library/dom';
11-
import { treeMock } from '../__mocks__/treeMock';
12+
13+
import { treeMock } from '../__mocks__/tree.mock';
1214

1315
jest.mock('../../src/webview/state', () => {
1416
return {

packages/webapp/test/Header/Header.test.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { treeMock } from '../__mocks__/treeMock';
21
import React from 'react';
3-
import { Header } from '../../src/webview/ui/components/Header';
42
import { render, cleanup } from '@testing-library/react';
5-
import { initI18n } from '../../src/webview/i18n';
63
import { Provider } from 'react-redux';
74
import configureMockStore from 'redux-mock-store';
5+
6+
import { initI18n } from '../../src/webview/i18n';
7+
import { Header } from '../../src/webview/ui/components/Header';
88
import { getInitialState, reducer } from '../../src/webview/state/reducers';
99
import type { AppState } from '../../src/webview/types';
1010

11+
import { treeMock } from '../__mocks__/tree.mock';
12+
1113
const createState = (initialState: AppState) => (actions: any[]) => actions.reduce(reducer, initialState);
1214
const mockStore = configureMockStore();
1315

packages/webapp/test/Header/NavigationButtons.test.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import { treeMock } from '../__mocks__/treeMock';
21
import React from 'react';
3-
import { actions } from '../../src/webview/state';
2+
import { Provider } from 'react-redux';
3+
import configureMockStore from 'redux-mock-store';
44
import { render, fireEvent, cleanup } from '@testing-library/react';
55
import { screen } from '@testing-library/dom';
6+
67
import {
78
HomeButton,
89
BackButton,
910
RestartButton,
1011
ShareButton,
1112
BookmarkButton
1213
} from '../../src/webview/ui/components/Header/NavigationButtons';
14+
import { actions } from '../../src/webview/state';
1315
import { initI18n } from '../../src/webview/i18n';
14-
import configureMockStore from 'redux-mock-store';
1516
import { getInitialState, reducer } from '../../src/webview/state/reducers';
1617
import { AppState } from '../../src/webview/types';
17-
import { Provider } from 'react-redux';
18+
19+
import { treeMock } from '../__mocks__/tree.mock';
1820

1921
jest.mock('../../src/webview/state', () => {
2022
return {

packages/webapp/test/Header/SearchField.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { SearchField } from '../../src/webview/ui/components/Header/SearchField'
99

1010
import * as treeUtils from '../../src/webview/features/Trees/Trees.utils';
1111

12-
import { render, appState } from '../__mocks__/storeMock';
12+
import { render, appState } from '../__mocks__/store.mock';
1313

1414
describe('<SearchField />', () => {
1515
initIcons();

packages/webapp/test/__mocks__/storeMock.tsx packages/webapp/test/__mocks__/store.mock.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { I18nextProvider } from 'react-i18next';
1212
import type { AppState } from '../../src/webview/types';
1313
import { reducer } from '../../src/webview/state/reducers';
1414

15-
import i18nMock from './i18nMock';
15+
import i18nMock from './i18n.mock';
1616

1717
interface WrapperProps {
1818
children?: React.ReactNode;

sonar-project.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sonar.inclusions=**/*.ts, **/*.tsx, **/*.scss
55
sonar.exclusions=**/*.test.ts, **/*.test.tsx
66
sonar.cpd.exclusions=**/i18n.ts
77
sonar.tests=.
8-
sonar.test.inclusions=**/*.test.ts, **/*.test.tsx
8+
sonar.test.inclusions=**/*.test.ts, **/*.test.tsx, **/*.mock.ts, **/*.mock.tsx
99
sonar.javascript.lcov.reportPaths=packages/core/coverage/lcov.info, \
1010
packages/ide-extension/coverage/lcov.info, \
1111
packages/types/coverage/lcov.info, \

0 commit comments

Comments
 (0)