3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import { screen } from '@testing-library/react';
21 import * as React from 'react';
22 import { searchRules } from '../../../../../../../api/rules';
23 import { mockLanguage, mockQualityProfile } from '../../../../../../../helpers/testMocks';
24 import { renderComponent } from '../../../../../../../helpers/testReactTestingUtils';
25 import { SearchRulesResponse } from '../../../../../../../types/coding-rules';
26 import { Dict } from '../../../../../../../types/types';
27 import { MetaQualityProfiles } from '../MetaQualityProfiles';
29 jest.mock('../../../../../../../api/rules', () => {
31 searchRules: jest.fn().mockResolvedValue({
37 it('should render correctly', async () => {
38 const totals: Dict<number> = {
43 jest.mocked(searchRules).mockImplementation(({ qprofile }: { qprofile: string }) => {
44 return Promise.resolve({ total: totals[qprofile] } as SearchRulesResponse);
47 renderMetaQualityprofiles();
49 expect(await screen.findByText('overview.deleted_profile.javascript')).toBeInTheDocument();
50 expect(screen.getByText('overview.deprecated_profile.10')).toBeInTheDocument();
53 function renderMetaQualityprofiles(overrides: Partial<MetaQualityProfiles['props']> = {}) {
54 return renderComponent(
56 languages={{ css: mockLanguage() }}
58 { ...mockQualityProfile({ key: 'js', name: 'javascript' }), deleted: true },
59 { ...mockQualityProfile({ key: 'ts', name: 'typescript' }), deleted: false },
61 ...mockQualityProfile({