Add tests for VersioningStrategy

Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
Erik Engervall
2021-04-18 12:48:37 +02:00
parent 3c32dccfde
commit 54e6abccb1
3 changed files with 54 additions and 1 deletions
@@ -0,0 +1,48 @@
/*
* Copyright 2021 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { render } from '@testing-library/react';
import {
mockCalverProject,
mockSearchCalver,
} from '../../test-helpers/test-helpers';
import { TEST_IDS } from '../../test-helpers/test-ids';
jest.mock('react-router', () => ({
useNavigate: jest.fn(),
useLocation: jest.fn(() => ({
search: mockSearchCalver,
})),
}));
jest.mock('../../contexts/ProjectContext', () => ({
useProjectContext: jest.fn(() => mockCalverProject),
}));
import { VersioningStrategy } from './VersioningStrategy';
describe('Repo', () => {
beforeEach(jest.clearAllMocks);
it('should render radio group', async () => {
const { getByTestId } = render(<VersioningStrategy />);
expect(
getByTestId(TEST_IDS.form.versioningStrategy.radioGroup),
).toBeInTheDocument();
});
});
@@ -24,8 +24,9 @@ import {
RadioGroup,
} from '@material-ui/core';
import { Project, useProjectContext } from '../../contexts/ProjectContext';
import { useProjectContext } from '../../contexts/ProjectContext';
import { useQueryHandler } from '../../hooks/useQueryHandler';
import { TEST_IDS } from '../../test-helpers/test-ids';
export function VersioningStrategy() {
const navigate = useNavigate();
@@ -50,6 +51,7 @@ export function VersioningStrategy() {
<FormControl component="fieldset" required>
<FormLabel component="legend">Calendar strategy</FormLabel>
<RadioGroup
data-testid={TEST_IDS.form.versioningStrategy.radioGroup}
aria-label="calendar-strategy"
name="calendar-strategy"
value={project.versioningStrategy}
@@ -48,6 +48,9 @@ export const TEST_IDS = {
error: 'grm--form--repo--error',
empty: 'grm--form--repo--empty',
},
versioningStrategy: {
radioGroup: 'grm--form--versioning-strategy--radio-group',
},
},
components: {
divider: 'grm--divider',