--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+import exposeLibraries from '../exposeLibraries';
+
+let warnSpy: jest.SpyInstance;
+
+beforeEach(() => {
+ warnSpy = jest.spyOn(console, 'warn');
+});
+
+it('should run the deprecation notice', () => {
+ exposeLibraries();
+
+ const { SonarHelpers, SonarMeasures, SonarComponents } = window as any;
+
+ expect(SonarHelpers).not.toBeNull();
+ expect(SonarMeasures).not.toBeNull();
+ expect(SonarComponents).not.toBeNull();
+ expect(warnSpy).toHaveBeenCalledTimes(3);
+});
const exposeLibraries = () => {
const global = window as any;
- global.SonarHelpers = {
- getBranchLikeQuery,
- isBranch,
- isMainBranch,
- isPullRequest,
- getStandards,
- renderCWECategory,
- renderOwaspTop10Category,
- renderSansTop25Category,
- renderSonarSourceSecurityCategory,
- getComponentIssuesUrl,
- getComponentSecurityHotspotsUrl,
- getRulesUrl
- };
- global.SonarMeasures = { ...measures, formatMeasure };
global.SonarRequest = {
request,
get,
throwGlobalError,
addGlobalSuccessMessage
};
- global.SonarComponents = {
- A11ySkipTarget,
- ActionsDropdown,
- ActionsDropdownItem,
- Alert,
- AlertErrorIcon,
- AlertSuccessIcon,
- AlertWarnIcon,
- BranchIcon: BranchLikeIcon,
- Button,
- Checkbox,
- CheckIcon,
- ClearIcon,
- ConfirmButton,
- CoverageRating,
- DateFormatter,
- DateFromNow,
- DateTimeFormatter,
- DeferredSpinner,
- DetachIcon,
- Dropdown,
- DropdownIcon,
- DuplicationsRating,
- EditButton,
- Favorite,
- FormattedMessage,
- HelpIcon,
- HelpTooltip,
- HomePageSelect,
- Level,
- ListFooter,
- LockIcon,
- LongLivingBranchIcon: BranchIcon,
- Modal,
- NotFound,
- PlusCircleIcon,
- PullRequestIcon,
- QualifierIcon,
- RadioToggle,
- Rating,
- ReloadButton,
- ResetButtonLink,
- SearchBox,
- SearchSelect,
- SecurityHotspotIcon,
- Select,
- SelectList,
- SimpleModal,
- SubmitButton,
- Suggestions,
- Tooltip,
- VulnerabilityIcon
- };
-
global.t = translate;
global.tp = translateWithParameters;
+
+ /**
+ * @deprecated since SonarQube 8.7
+ */
+ Object.defineProperty(global, 'SonarHelpers', {
+ get: () => {
+ // eslint-disable-next-line no-console
+ console.warn('SonarHelpers usages are deprecated since SonarQube 8.7');
+ return {
+ getBranchLikeQuery,
+ isBranch,
+ isMainBranch,
+ isPullRequest,
+ getStandards,
+ renderCWECategory,
+ renderOwaspTop10Category,
+ renderSansTop25Category,
+ renderSonarSourceSecurityCategory,
+ getComponentIssuesUrl,
+ getComponentSecurityHotspotsUrl,
+ getRulesUrl
+ };
+ }
+ });
+
+ /**
+ * @deprecated since SonarQube 8.7
+ */
+ Object.defineProperty(global, 'SonarMeasures', {
+ get: () => {
+ // eslint-disable-next-line no-console
+ console.warn('SonarMeasures usages are deprecated since SonarQube 8.7');
+ return { ...measures, formatMeasure };
+ }
+ });
+
+ /**
+ * @deprecated since SonarQube 8.7
+ */
+ Object.defineProperty(global, 'SonarComponents', {
+ get: () => {
+ // eslint-disable-next-line no-console
+ console.warn('SonarComponents usages are deprecated since SonarQube 8.7');
+ return {
+ A11ySkipTarget,
+ ActionsDropdown,
+ ActionsDropdownItem,
+ Alert,
+ AlertErrorIcon,
+ AlertSuccessIcon,
+ AlertWarnIcon,
+ BranchIcon: BranchLikeIcon,
+ Button,
+ Checkbox,
+ CheckIcon,
+ ClearIcon,
+ ConfirmButton,
+ CoverageRating,
+ DateFormatter,
+ DateFromNow,
+ DateTimeFormatter,
+ DeferredSpinner,
+ DetachIcon,
+ Dropdown,
+ DropdownIcon,
+ DuplicationsRating,
+ EditButton,
+ Favorite,
+ FormattedMessage,
+ HelpIcon,
+ HelpTooltip,
+ HomePageSelect,
+ Level,
+ ListFooter,
+ LockIcon,
+ LongLivingBranchIcon: BranchIcon,
+ Modal,
+ NotFound,
+ PlusCircleIcon,
+ PullRequestIcon,
+ QualifierIcon,
+ RadioToggle,
+ Rating,
+ ReloadButton,
+ ResetButtonLink,
+ SearchBox,
+ SearchSelect,
+ SecurityHotspotIcon,
+ Select,
+ SelectList,
+ SimpleModal,
+ SubmitButton,
+ Suggestions,
+ Tooltip,
+ VulnerabilityIcon
+ };
+ }
+ });
};
export default exposeLibraries;