aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/design-system/src/components/__tests__
diff options
context:
space:
mode:
authorstanislavh <stanislav.honcharov@sonarsource.com>2024-04-29 12:32:22 +0200
committerMatteo Mara <matteo.mara@sonarsource.com>2024-04-30 10:59:05 +0200
commit7067c5cd8c035cb83bde3562f01462d44a768133 (patch)
tree8db30c360a4f3c8ae38076882f94cc8f9ab5f6bc /server/sonar-web/design-system/src/components/__tests__
parent639bde5900dc8b71bffbc72dcadb8a10660777a6 (diff)
downloadsonarqube-7067c5cd8c035cb83bde3562f01462d44a768133.tar.gz
sonarqube-7067c5cd8c035cb83bde3562f01462d44a768133.zip
SONAR-22049 Move ToggleButton to sonar-aligned folder
Diffstat (limited to 'server/sonar-web/design-system/src/components/__tests__')
-rw-r--r--server/sonar-web/design-system/src/components/__tests__/ToggleButton-test.tsx66
1 files changed, 0 insertions, 66 deletions
diff --git a/server/sonar-web/design-system/src/components/__tests__/ToggleButton-test.tsx b/server/sonar-web/design-system/src/components/__tests__/ToggleButton-test.tsx
deleted file mode 100644
index f28e9ad443d..00000000000
--- a/server/sonar-web/design-system/src/components/__tests__/ToggleButton-test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 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 { screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import { getTabPanelId } from '../../helpers';
-import { render } from '../../helpers/testUtils';
-import { FCProps } from '../../types/misc';
-import { ToggleButton, ToggleButtonsOption } from '../ToggleButton';
-
-it('should render all options', async () => {
- const user = userEvent.setup();
- const onChange = jest.fn();
- const options: Array<ToggleButtonsOption<number>> = [
- { value: 1, label: 'first' },
- { value: 2, label: 'disabled', disabled: true },
- { value: 3, label: 'has counter', counter: 7 },
- ];
- renderToggleButtons({ onChange, options, value: 1 });
-
- expect(screen.getAllByRole('radio')).toHaveLength(3);
-
- await user.click(screen.getByText('first'));
-
- expect(onChange).not.toHaveBeenCalled();
-
- await user.click(screen.getByText('has counter'));
-
- expect(onChange).toHaveBeenCalledWith(3);
-});
-
-it('should work in tablist mode', () => {
- const onChange = jest.fn();
- const options: Array<ToggleButtonsOption<number>> = [
- { value: 1, label: 'first' },
- { value: 2, label: 'second' },
- { value: 3, label: 'third' },
- ];
- renderToggleButtons({ onChange, options, value: 1, role: 'tablist' });
-
- expect(screen.getAllByRole('tab')).toHaveLength(3);
- expect(screen.getByRole('tab', { name: 'second' })).toHaveAttribute(
- 'aria-controls',
- getTabPanelId(2),
- );
-});
-
-function renderToggleButtons(props: Partial<FCProps<typeof ToggleButton>> = {}) {
- return render(<ToggleButton onChange={jest.fn()} options={[]} {...props} />);
-}