diff --git a/plugins/github-release-manager/src/cards/RepoDetailsForm/VersioningStrategy.test.tsx b/plugins/github-release-manager/src/cards/RepoDetailsForm/VersioningStrategy.test.tsx
index 9790fba23a..bc27ea4ce1 100644
--- a/plugins/github-release-manager/src/cards/RepoDetailsForm/VersioningStrategy.test.tsx
+++ b/plugins/github-release-manager/src/cards/RepoDetailsForm/VersioningStrategy.test.tsx
@@ -15,22 +15,23 @@
*/
import React from 'react';
-import { render } from '@testing-library/react';
+import { render, fireEvent } from '@testing-library/react';
import {
- mockCalverProject,
+ mockSemverProject,
mockSearchCalver,
} from '../../test-helpers/test-helpers';
-import { TEST_IDS } from '../../test-helpers/test-ids';
+
+const mockNavigate = jest.fn();
jest.mock('react-router', () => ({
- useNavigate: jest.fn(),
+ useNavigate: () => mockNavigate,
useLocation: jest.fn(() => ({
search: mockSearchCalver,
})),
}));
jest.mock('../../contexts/ProjectContext', () => ({
- useProjectContext: jest.fn(() => mockCalverProject),
+ useProjectContext: jest.fn(() => mockSemverProject),
}));
import { VersioningStrategy } from './VersioningStrategy';
@@ -38,11 +39,25 @@ import { VersioningStrategy } from './VersioningStrategy';
describe('Repo', () => {
beforeEach(jest.clearAllMocks);
- it('should render radio group', async () => {
- const { getByTestId } = render();
+ it('should render radio group with default values and handle changes', async () => {
+ const { getByLabelText } = render();
- expect(
- getByTestId(TEST_IDS.form.versioningStrategy.radioGroup),
- ).toBeInTheDocument();
+ const radio1 = getByLabelText('Semantic versioning');
+ const radio2 = getByLabelText('Calendar versioning');
+
+ expect(radio1).toBeChecked();
+ expect(radio2).not.toBeChecked();
+
+ fireEvent.click(radio2);
+ expect(mockNavigate.mock.calls).toMatchInlineSnapshot(`
+ Array [
+ Array [
+ "?versioningStrategy=calver&owner=mock_owner&repo=mock_repo",
+ Object {
+ "replace": true,
+ },
+ ],
+ ]
+ `);
});
});
diff --git a/plugins/github-release-manager/src/constants/constants.test.ts b/plugins/github-release-manager/src/constants/constants.test.ts
index 3441221821..cf2b7d7548 100644
--- a/plugins/github-release-manager/src/constants/constants.test.ts
+++ b/plugins/github-release-manager/src/constants/constants.test.ts
@@ -30,6 +30,10 @@ describe('constants', () => {
"minor": "minor",
"patch": "patch",
},
+ "VERSIONING_STRATEGIES": Object {
+ "calver": "calver",
+ "semver": "semver",
+ },
}
`);
});