@@ -25,8 +25,10 @@ import {
|
||||
mockReleaseVersionCalver,
|
||||
mockSemverProject,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { CreateRc } from './CreateRc';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { useCreateRc } from './hooks/useCreateRc';
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => ({
|
||||
@@ -46,9 +48,6 @@ jest.mock('./hooks/useCreateRc', () => ({
|
||||
} as ReturnType<typeof useCreateRc>),
|
||||
}));
|
||||
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { CreateRc } from './CreateRc';
|
||||
|
||||
describe('CreateRc', () => {
|
||||
it('should display CTA', () => {
|
||||
const { getByTestId } = render(
|
||||
|
||||
@@ -26,10 +26,9 @@ import {
|
||||
} from '../../../test-helpers/test-helpers';
|
||||
import { useCreateRc } from './useCreateRc';
|
||||
|
||||
jest.mock('../../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('useCreateRc', () => {
|
||||
|
||||
@@ -17,13 +17,17 @@
|
||||
import React from 'react';
|
||||
import { render, act, waitFor } from '@testing-library/react';
|
||||
|
||||
import { Features } from './Features';
|
||||
import { mockApiClient, mockCalverProject } from '../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
ErrorBoundary: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
InfoCard: ({ children }: { children: React.ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
jest.mock('../contexts/ProjectContext', () => ({
|
||||
useProjectContext: () => ({
|
||||
@@ -31,8 +35,6 @@ jest.mock('../contexts/ProjectContext', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { Features } from './Features';
|
||||
|
||||
describe('Features', () => {
|
||||
it('should omit features omitted via configuration', async () => {
|
||||
const { getByTestId } = render(
|
||||
@@ -52,7 +54,7 @@ describe('Features', () => {
|
||||
|
||||
expect(getByTestId(TEST_IDS.info.info)).toMatchInlineSnapshot(`
|
||||
<div
|
||||
class="MuiBox-root MuiBox-root-11"
|
||||
class="MuiBox-root MuiBox-root-4"
|
||||
data-testid="grm--info"
|
||||
>
|
||||
<h6
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
mockReleaseBranch,
|
||||
mockReleaseCandidateCalver,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { Info } from './Info';
|
||||
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: () => ({
|
||||
@@ -29,8 +30,6 @@ jest.mock('../../contexts/ProjectContext', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { Info } from './Info';
|
||||
|
||||
describe('Info', () => {
|
||||
it('should return early if no latestRelease exists', async () => {
|
||||
const { findByText } = render(
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
mockCalverProject,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { Patch } from './Patch';
|
||||
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: () => ({
|
||||
@@ -29,8 +30,6 @@ jest.mock('../../contexts/ProjectContext', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { Patch } from './Patch';
|
||||
|
||||
describe('Patch', () => {
|
||||
it('should return early if no latestRelease exists', () => {
|
||||
const { getByTestId } = render(
|
||||
|
||||
@@ -26,11 +26,12 @@ import {
|
||||
mockReleaseVersionCalver,
|
||||
mockTagParts,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { PatchBody } from './PatchBody';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: () => ({
|
||||
@@ -45,9 +46,6 @@ jest.mock('./hooks/usePatch', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { PatchBody } from './PatchBody';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
describe('PatchBody', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ import {
|
||||
} from '../../../test-helpers/test-helpers';
|
||||
import { usePatch } from './usePatch';
|
||||
|
||||
jest.mock('../../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('patch', () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
mockReleaseVersionCalver,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { PromoteRc } from './PromoteRc';
|
||||
|
||||
jest.mock('./PromoteRcBody', () => ({
|
||||
PromoteRcBody: () => (
|
||||
@@ -29,8 +30,6 @@ jest.mock('./PromoteRcBody', () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
import { PromoteRc } from './PromoteRc';
|
||||
|
||||
describe('PromoteRc', () => {
|
||||
it('return early if no latest release present', () => {
|
||||
const { getByTestId } = render(<PromoteRc latestRelease={null} />);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { render } from '@testing-library/react';
|
||||
|
||||
import { mockReleaseCandidateCalver } from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { PromoteRcBody } from './PromoteRcBody';
|
||||
|
||||
jest.mock('./hooks/usePromoteRc', () => ({
|
||||
usePromoteRc: () => ({
|
||||
@@ -28,8 +29,6 @@ jest.mock('./hooks/usePromoteRc', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { PromoteRcBody } from './PromoteRcBody';
|
||||
|
||||
describe('PromoteRcBody', () => {
|
||||
it('should display CTA', () => {
|
||||
const { getByTestId } = render(
|
||||
|
||||
@@ -24,10 +24,9 @@ import {
|
||||
} from '../../../test-helpers/test-helpers';
|
||||
import { usePromoteRc } from './usePromoteRc';
|
||||
|
||||
jest.mock('../../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: () => ({
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
mockSearchCalver,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { Owner } from './Owner';
|
||||
|
||||
jest.mock('react-router', () => ({
|
||||
useNavigate: jest.fn(),
|
||||
@@ -30,10 +32,9 @@ jest.mock('react-router', () => ({
|
||||
search: mockSearchCalver,
|
||||
})),
|
||||
}));
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => ({
|
||||
@@ -41,9 +42,6 @@ jest.mock('../../contexts/ProjectContext', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { Owner } from './Owner';
|
||||
|
||||
describe('Owner', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
mockSearchCalver,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { Repo } from './Repo';
|
||||
|
||||
jest.mock('react-router', () => ({
|
||||
useNavigate: jest.fn(),
|
||||
@@ -30,10 +32,9 @@ jest.mock('react-router', () => ({
|
||||
search: mockSearchCalver,
|
||||
})),
|
||||
}));
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: () => ({
|
||||
pluginApiClient: mockApiClient,
|
||||
}),
|
||||
jest.mock('@backstage/core', () => ({
|
||||
useApi: () => mockApiClient,
|
||||
createApiRef: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => ({
|
||||
@@ -41,9 +42,6 @@ jest.mock('../../contexts/ProjectContext', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { Repo } from './Repo';
|
||||
|
||||
describe('Repo', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
|
||||
+1
-2
@@ -21,6 +21,7 @@ import {
|
||||
mockSemverProject,
|
||||
mockSearchCalver,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { VersioningStrategy } from './VersioningStrategy';
|
||||
|
||||
const mockNavigate = jest.fn();
|
||||
|
||||
@@ -36,8 +37,6 @@ jest.mock('../../contexts/ProjectContext', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { VersioningStrategy } from './VersioningStrategy';
|
||||
|
||||
describe('Repo', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ import {
|
||||
mockCalverProject,
|
||||
mockSemverProject,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { getCalverTagParts } from './getCalverTagParts';
|
||||
import { getSemverTagParts } from './getSemverTagParts';
|
||||
import { getTagParts } from './getTagParts';
|
||||
|
||||
jest.mock('./getCalverTagParts', () => ({
|
||||
getCalverTagParts: jest.fn(),
|
||||
@@ -26,10 +29,6 @@ jest.mock('./getSemverTagParts', () => ({
|
||||
getSemverTagParts: jest.fn(),
|
||||
}));
|
||||
|
||||
import { getCalverTagParts } from './getCalverTagParts';
|
||||
import { getSemverTagParts } from './getSemverTagParts';
|
||||
import { getTagParts } from './getTagParts';
|
||||
|
||||
describe('getTagParts', () => {
|
||||
beforeEach(jest.resetAllMocks);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { mockSearchSemver } from '../test-helpers/test-helpers';
|
||||
import { useQueryHandler } from './useQueryHandler';
|
||||
|
||||
jest.mock('react-router', () => ({
|
||||
useLocation: jest.fn(() => ({
|
||||
@@ -25,8 +26,6 @@ jest.mock('react-router', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
import { useQueryHandler } from './useQueryHandler';
|
||||
|
||||
const TEST_ID = 'grm--use-query-handler';
|
||||
|
||||
const MockComponent = () => {
|
||||
|
||||
Reference in New Issue
Block a user