diff --git a/packages/webapp/jest.config.js b/packages/webapp/jest.config.js index 5743ecea..792be9b7 100644 --- a/packages/webapp/jest.config.js +++ b/packages/webapp/jest.config.js @@ -26,7 +26,7 @@ module.exports = { '.+\\.(css|sass|scss)$': 'jest-css-modules-transform' }, moduleNameMapper: { - '.+\\.(svg)$': '/test/__mocks__/svgMock.ts', + '.+\\.(svg)$': '/test/__mocks__/svg.mock.ts', uuid: require.resolve('uuid') }, transformIgnorePatterns: ['/node_modules/'], diff --git a/packages/webapp/test/App.test.tsx b/packages/webapp/test/App.test.tsx index 8ce20c42..e8368f41 100644 --- a/packages/webapp/test/App.test.tsx +++ b/packages/webapp/test/App.test.tsx @@ -6,7 +6,7 @@ import { initI18n } from '../src/webview/i18n'; import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store'; import { getInitialState, reducer } from '../src/webview/state/reducers'; -import { treeMock } from './__mocks__/treeMock'; +import { treeMock } from './__mocks__/tree.mock'; jest.mock('../src/webview/state', () => { return { diff --git a/packages/webapp/test/FeedbackSection/FeedbackSection.test.tsx b/packages/webapp/test/FeedbackSection/FeedbackSection.test.tsx index d20615be..e8007d2e 100644 --- a/packages/webapp/test/FeedbackSection/FeedbackSection.test.tsx +++ b/packages/webapp/test/FeedbackSection/FeedbackSection.test.tsx @@ -8,21 +8,23 @@ import configureMockStore from 'redux-mock-store'; import { getInitialState, reducer } from '../../src/webview/state/reducers'; import { AppState } from '../../src/webview/types'; import { useSelector } from 'react-redux'; -import { treeMock } from '../__mocks__/treeMock'; +import { treeMock } from '../__mocks__/tree.mock'; const initialState = { ...getInitialState(), activeGuidedAnswer: treeMock, - activeGuidedAnswerNode: [{ - BODY: '

SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code

', - EDGES: [ - { LABEL: 'Deployment', TARGET_NODE: 45996, ORD: 1 }, - { LABEL: 'Fiori Generator', TARGET_NODE: 48363, ORD: 2 } - ], - NODE_ID: 45995, - QUESTION: 'I have a problem with', - TITLE: 'SAP Fiori Tools' - }] + activeGuidedAnswerNode: [ + { + BODY: '

SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code

', + EDGES: [ + { LABEL: 'Deployment', TARGET_NODE: 45996, ORD: 1 }, + { LABEL: 'Fiori Generator', TARGET_NODE: 48363, ORD: 2 } + ], + NODE_ID: 45995, + QUESTION: 'I have a problem with', + TITLE: 'SAP Fiori Tools' + } + ] }; jest.mock('../../src/webview/state', () => { diff --git a/packages/webapp/test/GuidedAnswerNode/Middle.test.tsx b/packages/webapp/test/GuidedAnswerNode/Middle.test.tsx index 82848463..db4de7cd 100644 --- a/packages/webapp/test/GuidedAnswerNode/Middle.test.tsx +++ b/packages/webapp/test/GuidedAnswerNode/Middle.test.tsx @@ -1,12 +1,14 @@ -import { treeMock } from '../__mocks__/treeMock'; import React, { ReactElement } from 'react'; import { useSelector } from 'react-redux'; import { render, fireEvent, cleanup } from '@testing-library/react'; import { screen } from '@testing-library/dom'; + import { Middle } from '../../src/webview/ui/components/GuidedAnswerNode/Middle'; import { actions } from '../../src/webview/state'; import { initI18n } from '../../src/webview/i18n'; +import { treeMock } from '../__mocks__/tree.mock'; + let activeNodeMock = { BODY: '

SAP Fiori Tools is a set of extensions for SAP Business Application Studio and Visual Studio Code

', EDGES: [ diff --git a/packages/webapp/test/Header/Filters.test.tsx b/packages/webapp/test/Header/Filters.test.tsx index a431d234..8048d98d 100644 --- a/packages/webapp/test/Header/Filters.test.tsx +++ b/packages/webapp/test/Header/Filters.test.tsx @@ -1,4 +1,3 @@ -import { treeMock } from '../__mocks__/treeMock'; import React from 'react'; import { render, fireEvent, cleanup } from '@testing-library/react'; import { initI18n } from '../../src/webview/i18n'; @@ -13,6 +12,8 @@ import { sortComponentFilters } from '../../src/webview/ui/components/Header/Filters/Filters'; +import { treeMock } from '../__mocks__/tree.mock'; + const createState = (initialState: AppState) => (actions: any[]) => actions.reduce(reducer, initialState); const mockStore = configureMockStore(); diff --git a/packages/webapp/test/Header/FiltersRibbon.test.tsx b/packages/webapp/test/Header/FiltersRibbon.test.tsx index c18f35e4..b5c47888 100644 --- a/packages/webapp/test/Header/FiltersRibbon.test.tsx +++ b/packages/webapp/test/Header/FiltersRibbon.test.tsx @@ -1,14 +1,16 @@ import React from 'react'; +import { Provider } from 'react-redux'; +import configureMockStore from 'redux-mock-store'; +import { screen } from '@testing-library/dom'; import { render, fireEvent, cleanup } from '@testing-library/react'; + import { initI18n } from '../../src/webview/i18n'; import { FiltersRibbon } from '../../src/webview/ui/components/Header/Filters/FiltersRibbon'; import { actions } from '../../src/webview/state'; -import { Provider } from 'react-redux'; import { getInitialState, reducer } from '../../src/webview/state/reducers'; import { AppState } from '../../src/webview/types'; -import configureMockStore from 'redux-mock-store'; -import { screen } from '@testing-library/dom'; -import { treeMock } from '../__mocks__/treeMock'; + +import { treeMock } from '../__mocks__/tree.mock'; jest.mock('../../src/webview/state', () => { return { diff --git a/packages/webapp/test/Header/Header.test.tsx b/packages/webapp/test/Header/Header.test.tsx index 2b722f28..1508c4de 100644 --- a/packages/webapp/test/Header/Header.test.tsx +++ b/packages/webapp/test/Header/Header.test.tsx @@ -1,13 +1,15 @@ -import { treeMock } from '../__mocks__/treeMock'; import React from 'react'; -import { Header } from '../../src/webview/ui/components/Header'; import { render, cleanup } from '@testing-library/react'; -import { initI18n } from '../../src/webview/i18n'; import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store'; + +import { initI18n } from '../../src/webview/i18n'; +import { Header } from '../../src/webview/ui/components/Header'; import { getInitialState, reducer } from '../../src/webview/state/reducers'; import type { AppState } from '../../src/webview/types'; +import { treeMock } from '../__mocks__/tree.mock'; + const createState = (initialState: AppState) => (actions: any[]) => actions.reduce(reducer, initialState); const mockStore = configureMockStore(); diff --git a/packages/webapp/test/Header/NavigationButtons.test.tsx b/packages/webapp/test/Header/NavigationButtons.test.tsx index 1a234708..a6cdeb2d 100644 --- a/packages/webapp/test/Header/NavigationButtons.test.tsx +++ b/packages/webapp/test/Header/NavigationButtons.test.tsx @@ -1,8 +1,9 @@ -import { treeMock } from '../__mocks__/treeMock'; import React from 'react'; -import { actions } from '../../src/webview/state'; +import { Provider } from 'react-redux'; +import configureMockStore from 'redux-mock-store'; import { render, fireEvent, cleanup } from '@testing-library/react'; import { screen } from '@testing-library/dom'; + import { HomeButton, BackButton, @@ -10,11 +11,12 @@ import { ShareButton, BookmarkButton } from '../../src/webview/ui/components/Header/NavigationButtons'; +import { actions } from '../../src/webview/state'; import { initI18n } from '../../src/webview/i18n'; -import configureMockStore from 'redux-mock-store'; import { getInitialState, reducer } from '../../src/webview/state/reducers'; import { AppState } from '../../src/webview/types'; -import { Provider } from 'react-redux'; + +import { treeMock } from '../__mocks__/tree.mock'; jest.mock('../../src/webview/state', () => { return { diff --git a/packages/webapp/test/Header/SearchField.test.tsx b/packages/webapp/test/Header/SearchField.test.tsx index 519edb1f..89e4059a 100644 --- a/packages/webapp/test/Header/SearchField.test.tsx +++ b/packages/webapp/test/Header/SearchField.test.tsx @@ -9,7 +9,7 @@ import { SearchField } from '../../src/webview/ui/components/Header/SearchField' import * as treeUtils from '../../src/webview/features/Trees/Trees.utils'; -import { render, appState } from '../__mocks__/storeMock'; +import { render, appState } from '../__mocks__/store.mock'; describe('', () => { initIcons(); diff --git a/packages/webapp/test/__mocks__/i18nMock.ts b/packages/webapp/test/__mocks__/i18n.mock.ts similarity index 100% rename from packages/webapp/test/__mocks__/i18nMock.ts rename to packages/webapp/test/__mocks__/i18n.mock.ts diff --git a/packages/webapp/test/__mocks__/storeMock.tsx b/packages/webapp/test/__mocks__/store.mock.tsx similarity index 97% rename from packages/webapp/test/__mocks__/storeMock.tsx rename to packages/webapp/test/__mocks__/store.mock.tsx index ad7a222a..fe481bcb 100644 --- a/packages/webapp/test/__mocks__/storeMock.tsx +++ b/packages/webapp/test/__mocks__/store.mock.tsx @@ -12,7 +12,7 @@ import { I18nextProvider } from 'react-i18next'; import type { AppState } from '../../src/webview/types'; import { reducer } from '../../src/webview/state/reducers'; -import i18nMock from './i18nMock'; +import i18nMock from './i18n.mock'; interface WrapperProps { children?: React.ReactNode; diff --git a/packages/webapp/test/__mocks__/svgMock.ts b/packages/webapp/test/__mocks__/svg.mock.ts similarity index 100% rename from packages/webapp/test/__mocks__/svgMock.ts rename to packages/webapp/test/__mocks__/svg.mock.ts diff --git a/packages/webapp/test/__mocks__/treeMock.ts b/packages/webapp/test/__mocks__/tree.mock.ts similarity index 100% rename from packages/webapp/test/__mocks__/treeMock.ts rename to packages/webapp/test/__mocks__/tree.mock.ts diff --git a/sonar-project.properties b/sonar-project.properties index 2b10a2d9..266463c6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -5,7 +5,7 @@ sonar.inclusions=**/*.ts, **/*.tsx, **/*.scss sonar.exclusions=**/*.test.ts, **/*.test.tsx sonar.cpd.exclusions=**/i18n.ts sonar.tests=. -sonar.test.inclusions=**/*.test.ts, **/*.test.tsx +sonar.test.inclusions=**/*.test.ts, **/*.test.tsx, **/*.mock.ts, **/*.mock.tsx sonar.javascript.lcov.reportPaths=packages/core/coverage/lcov.info, \ packages/ide-extension/coverage/lcov.info, \ packages/types/coverage/lcov.info, \