From 54e6abccb15a3ea845b0038ed81de51021086c40 Mon Sep 17 00:00:00 2001 From: Erik Engervall Date: Sun, 18 Apr 2021 12:48:37 +0200 Subject: [PATCH] Add tests for VersioningStrategy Signed-off-by: Erik Engervall --- .../projectForm/VersioningStrategy.test.tsx | 48 +++++++++++++++++++ .../cards/projectForm/VersioningStrategy.tsx | 4 +- .../src/test-helpers/test-ids.ts | 3 ++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.test.tsx diff --git a/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.test.tsx b/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.test.tsx new file mode 100644 index 0000000000..9790fba23a --- /dev/null +++ b/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.test.tsx @@ -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(); + + expect( + getByTestId(TEST_IDS.form.versioningStrategy.radioGroup), + ).toBeInTheDocument(); + }); +}); diff --git a/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.tsx b/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.tsx index 62b75722eb..23d42009df 100644 --- a/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.tsx +++ b/plugins/github-release-manager/src/cards/projectForm/VersioningStrategy.tsx @@ -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() { Calendar strategy