diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2022-06-14 11:52:43 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-06-14 20:02:51 +0000 |
commit | b7e212269e51acab068f74901fcde5bcd405436c (patch) | |
tree | 9d7e5c2338c35ab9cb033015026a66047daf07c2 /server | |
parent | 55e999d240d2b93c71f3802f72a3d35bae7f1794 (diff) | |
download | sonarqube-b7e212269e51acab068f74901fcde5bcd405436c.tar.gz sonarqube-b7e212269e51acab068f74901fcde5bcd405436c.zip |
[NO JIRA] Remove duplicate mockEvent() helper
Diffstat (limited to 'server')
23 files changed, 31 insertions, 47 deletions
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx index 4727c3deb92..edeee98bd8f 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/KeyboardShortcutsModal-test.tsx @@ -20,7 +20,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import Modal from '../../../components/controls/Modal'; -import { mockEvent } from '../../../helpers/testMocks'; +import { mockEvent } from '../../../helpers/testUtils'; import KeyboardShortcutsModal from '../KeyboardShortcutsModal'; jest.mock('react', () => { diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/CreateApplicationForm-test.tsx b/server/sonar-web/src/main/js/app/components/extensions/__tests__/CreateApplicationForm-test.tsx index 99f92780266..91dd44a17ac 100644 --- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/CreateApplicationForm-test.tsx +++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/CreateApplicationForm-test.tsx @@ -21,8 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { createApplication } from '../../../../api/application'; import SimpleModal from '../../../../components/controls/SimpleModal'; -import { mockEvent } from '../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import { ComponentQualifier, Visibility } from '../../../../types/component'; import CreateApplicationForm from '../CreateApplicationForm'; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/BulkChange-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/BulkChange-test.tsx index 01ec8016716..ba30cada723 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/BulkChange-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/BulkChange-test.tsx @@ -19,7 +19,8 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import { mockEvent, mockQualityProfile } from '../../../../helpers/testMocks'; +import { mockQualityProfile } from '../../../../helpers/testMocks'; +import { mockEvent } from '../../../../helpers/testUtils'; import BulkChange from '../BulkChange'; const profile = mockQualityProfile({ diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx index d216c2ae4f2..763fc8a2761 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/RuleListItem-test.tsx @@ -21,8 +21,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { Link } from 'react-router'; import { deactivateRule } from '../../../../api/quality-profiles'; -import { mockEvent, mockQualityProfile, mockRule } from '../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { mockQualityProfile, mockRule } from '../../../../helpers/testMocks'; +import { mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import RuleListItem from '../RuleListItem'; jest.mock('../../../../api/quality-profiles', () => ({ diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectAccordion-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectAccordion-test.tsx index 2b7a91f27fc..a99c243882f 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectAccordion-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/AzureProjectAccordion-test.tsx @@ -22,7 +22,7 @@ import * as React from 'react'; import BoxedGroupAccordion from '../../../../components/controls/BoxedGroupAccordion'; import Radio from '../../../../components/controls/Radio'; import { mockAzureProject, mockAzureRepository } from '../../../../helpers/mocks/alm-integrations'; -import { mockEvent } from '../../../../helpers/testMocks'; +import { mockEvent } from '../../../../helpers/testUtils'; import AzureProjectAccordion, { AzureProjectAccordionProps } from '../AzureProjectAccordion'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx index 5ae9c58bef7..7e4b38aed81 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/ManualProjectCreate-test.tsx @@ -24,8 +24,7 @@ import ProjectKeyInput from '../../../../components/common/ProjectKeyInput'; import { SubmitButton } from '../../../../components/controls/buttons'; import ValidationInput from '../../../../components/controls/ValidationInput'; import { validateProjectKey } from '../../../../helpers/projects'; -import { mockEvent } from '../../../../helpers/testMocks'; -import { change, submit, waitAndUpdate } from '../../../../helpers/testUtils'; +import { change, mockEvent, submit, waitAndUpdate } from '../../../../helpers/testUtils'; import { ProjectKeyValidationResult } from '../../../../types/component'; import { PROJECT_NAME_MAX_LEN } from '../constants'; import ManualProjectCreate from '../ManualProjectCreate'; diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx index 6b69a551563..015fe3499e3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/IssuesApp-test.tsx @@ -33,14 +33,13 @@ import { } from '../../../../helpers/pages'; import { mockCurrentUser, - mockEvent, mockIssue, mockLocation, mockLoggedInUser, mockRawIssue, mockRouter } from '../../../../helpers/testMocks'; -import { keydown, waitAndUpdate } from '../../../../helpers/testUtils'; +import { keydown, mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import { ComponentQualifier } from '../../../../types/component'; import { ReferencedComponent } from '../../../../types/issues'; import { Issue, Paging } from '../../../../types/types'; diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/App-test.tsx index e99eb125f1d..9ceb6e3b6e3 100644 --- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/App-test.tsx @@ -26,8 +26,8 @@ import { } from '../../../../api/newCodePeriod'; import { mockBranch, mockMainBranch, mockPullRequest } from '../../../../helpers/mocks/branch-like'; import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockAppState, mockEvent } from '../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { mockAppState } from '../../../../helpers/testMocks'; +import { mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import { App } from '../App'; jest.mock('../../../../api/newCodePeriod', () => ({ diff --git a/server/sonar-web/src/main/js/apps/projectKey/__tests__/UpdateForm-test.tsx b/server/sonar-web/src/main/js/apps/projectKey/__tests__/UpdateForm-test.tsx index 8734ba0ae8f..330b0c77326 100644 --- a/server/sonar-web/src/main/js/apps/projectKey/__tests__/UpdateForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectKey/__tests__/UpdateForm-test.tsx @@ -22,8 +22,7 @@ import * as React from 'react'; import ProjectKeyInput from '../../../components/common/ProjectKeyInput'; import { Button, SubmitButton } from '../../../components/controls/buttons'; import { mockComponent } from '../../../helpers/mocks/component'; -import { mockEvent } from '../../../helpers/testMocks'; -import { click } from '../../../helpers/testUtils'; +import { click, mockEvent } from '../../../helpers/testUtils'; import UpdateForm, { UpdateFormProps } from '../UpdateForm'; it('should render', () => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/DeleteProfileForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/DeleteProfileForm-test.tsx index 6d19a90c021..567a1a1d0fc 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/DeleteProfileForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/DeleteProfileForm-test.tsx @@ -19,7 +19,8 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import { mockEvent, mockQualityProfile } from '../../../../helpers/testMocks'; +import { mockQualityProfile } from '../../../../helpers/testMocks'; +import { mockEvent } from '../../../../helpers/testUtils'; import DeleteProfileForm, { DeleteProfileFormProps } from '../DeleteProfileForm'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileModalForm-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileModalForm-test.tsx index 9596d7844a0..d33c6e4fee8 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileModalForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileModalForm-test.tsx @@ -19,8 +19,8 @@ */ import { shallow } from 'enzyme'; import * as React from 'react'; -import { mockEvent, mockQualityProfile } from '../../../../helpers/testMocks'; -import { change } from '../../../../helpers/testUtils'; +import { mockQualityProfile } from '../../../../helpers/testMocks'; +import { change, mockEvent } from '../../../../helpers/testUtils'; import ProfileModalForm, { ProfileModalFormProps } from '../ProfileModalForm'; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-test.tsx index 5f1904aaa30..6793d859743 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-test.tsx @@ -30,13 +30,12 @@ import { scrollToElement } from '../../../helpers/scrolling'; import { getStandards } from '../../../helpers/security-standard'; import { mockCurrentUser, - mockEvent, mockFlowLocation, mockLocation, mockLoggedInUser, mockRouter } from '../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../helpers/testUtils'; +import { mockEvent, waitAndUpdate } from '../../../helpers/testUtils'; import { SecurityStandard } from '../../../types/security'; import { HotspotResolution, diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotViewerTabs-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotViewerTabs-test.tsx index 12033dedd99..ff4f7f8dcdc 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotViewerTabs-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotViewerTabs-test.tsx @@ -22,7 +22,8 @@ import * as React from 'react'; import BoxedTabs, { BoxedTabsProps } from '../../../../components/controls/BoxedTabs'; import { KeyboardKeys } from '../../../../helpers/keycodes'; import { mockHotspot, mockHotspotRule } from '../../../../helpers/mocks/security-hotspots'; -import { mockEvent, mockUser } from '../../../../helpers/testMocks'; +import { mockUser } from '../../../../helpers/testMocks'; +import { mockEvent } from '../../../../helpers/testUtils'; import HotspotViewerTabs, { TabKeys } from '../HotspotViewerTabs'; const originalAddEventListener = window.addEventListener; diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx index 69879aa7934..86b36dcb232 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmBindingDefinitionFormRenderer-test.tsx @@ -21,8 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { ResetButtonLink } from '../../../../../components/controls/buttons'; import { mockGithubBindingDefinition } from '../../../../../helpers/mocks/alm-settings'; -import { mockEvent } from '../../../../../helpers/testMocks'; -import { click } from '../../../../../helpers/testUtils'; +import { click, mockEvent } from '../../../../../helpers/testUtils'; import { AlmKeys } from '../../../../../types/alm-settings'; import AlmBindingDefinitionFormRenderer, { AlmBindingDefinitionFormProps diff --git a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.tsx index 010c32668c0..dbb912412f3 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/inputs/__tests__/SimpleInput-test.tsx @@ -21,8 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { KeyboardKeys } from '../../../../../helpers/keycodes'; import { mockSetting } from '../../../../../helpers/mocks/settings'; -import { mockEvent } from '../../../../../helpers/testMocks'; -import { change } from '../../../../../helpers/testUtils'; +import { change, mockEvent } from '../../../../../helpers/testUtils'; import SimpleInput, { SimpleInputProps } from '../SimpleInput'; it('should render input', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx index b3855d7c217..b8087369c6a 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx @@ -20,7 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { parseDate } from '../../../helpers/dates'; -import { mockEvent } from '../../../helpers/testMocks'; +import { mockEvent } from '../../../helpers/testUtils'; import GraphsTooltips from '../GraphsTooltips'; import { DEFAULT_GRAPH } from '../utils'; diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx index 16228f35107..f83cff62df4 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx +++ b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx @@ -25,8 +25,7 @@ import { Link } from 'react-router'; import { AutoSizer, AutoSizerProps } from 'react-virtualized/dist/commonjs/AutoSizer'; import { mockComponentMeasureEnhanced } from '../../../helpers/mocks/component'; import { mockHtmlElement } from '../../../helpers/mocks/dom'; -import { mockEvent } from '../../../helpers/testMocks'; -import { click } from '../../../helpers/testUtils'; +import { click, mockEvent } from '../../../helpers/testUtils'; import { ComponentMeasureEnhanced } from '../../../types/types'; import BubbleChart from '../BubbleChart'; diff --git a/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx index e8e2e1cf886..68788eb7fae 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/AnalysisWarningsModal-test.tsx @@ -21,8 +21,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { dismissAnalysisWarning, getTask } from '../../../api/ce'; import { mockTaskWarning } from '../../../helpers/mocks/tasks'; -import { mockCurrentUser, mockEvent } from '../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../helpers/testUtils'; +import { mockCurrentUser } from '../../../helpers/testMocks'; +import { mockEvent, waitAndUpdate } from '../../../helpers/testUtils'; import { AnalysisWarningsModal } from '../AnalysisWarningsModal'; jest.mock('../../../api/ce', () => ({ diff --git a/server/sonar-web/src/main/js/components/common/__tests__/ResetPasswordForm-test.tsx b/server/sonar-web/src/main/js/components/common/__tests__/ResetPasswordForm-test.tsx index ccb1b6536cc..83a56c9d804 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/ResetPasswordForm-test.tsx +++ b/server/sonar-web/src/main/js/components/common/__tests__/ResetPasswordForm-test.tsx @@ -20,8 +20,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { changePassword } from '../../../api/users'; -import { mockEvent, mockLoggedInUser } from '../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../helpers/testUtils'; +import { mockLoggedInUser } from '../../../helpers/testMocks'; +import { mockEvent, waitAndUpdate } from '../../../helpers/testUtils'; import ResetPasswordForm from '../ResetPasswordForm'; jest.mock('../../../api/users', () => ({ diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx index 176f99e936d..a062a3d0f81 100644 --- a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx +++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx @@ -20,7 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { scrollToElement } from '../../../helpers/scrolling'; -import { mockEvent } from '../../../helpers/testMocks'; +import { mockEvent } from '../../../helpers/testUtils'; import DocMarkdownBlock from '../DocMarkdownBlock'; const CONTENT = ` diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/CommentPopup-test.tsx b/server/sonar-web/src/main/js/components/issue/popups/__tests__/CommentPopup-test.tsx index 62fcb621c1c..95ed70f1af0 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/CommentPopup-test.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/CommentPopup-test.tsx @@ -20,8 +20,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { KeyboardKeys } from '../../../../helpers/keycodes'; -import { mockEvent } from '../../../../helpers/testMocks'; -import { click } from '../../../../helpers/testUtils'; +import { click, mockEvent } from '../../../../helpers/testUtils'; import CommentPopup, { CommentPopupProps } from '../CommentPopup'; it('should render the comment popup correctly without existing comment', () => { diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx index 91236c238fc..6e7c2f8354b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/EditTokenModal-test.tsx @@ -21,8 +21,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { generateToken, getTokens, revokeToken } from '../../../../api/user-tokens'; import { mockComponent } from '../../../../helpers/mocks/component'; -import { mockEvent, mockLoggedInUser } from '../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../helpers/testUtils'; +import { mockLoggedInUser } from '../../../../helpers/testMocks'; +import { mockEvent, waitAndUpdate } from '../../../../helpers/testUtils'; import { getUniqueTokenName } from '../../utils'; import EditTokenModal from '../EditTokenModal'; diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 80bab8e94d6..75c2f1b0daf 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -324,16 +324,6 @@ export function mockGroup(overrides: Partial<Group> = {}): Group { }; } -export function mockEvent(overrides = {}) { - return { - target: { blur() {} }, - currentTarget: { blur() {} }, - preventDefault() {}, - stopPropagation() {}, - ...overrides - } as any; -} - export function mockRawIssue(withLocations = false, overrides: Partial<RawIssue> = {}): RawIssue { const rawIssue: RawIssue = { actions: [], |