Fix tests (data-testid props weren't forwarded to CircularProgress)
Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
@@ -28,13 +28,17 @@ import {
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../components/ProjectContext', () => ({
|
||||
usePluginApiClientContext: () => mockApiClient,
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: jest.fn(() => mockApiClient),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => mockCalverProject),
|
||||
}));
|
||||
jest.mock('./getRcGitHubInfo', () => ({
|
||||
getRcGitHubInfo: () => mockNextGitHubInfo,
|
||||
}));
|
||||
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { CreateRc } from './CreateRc';
|
||||
|
||||
describe('CreateRc', () => {
|
||||
@@ -43,7 +47,6 @@ describe('CreateRc', () => {
|
||||
<CreateRc
|
||||
defaultBranch="mockDefaultBranch"
|
||||
latestRelease={mockRcRelease}
|
||||
project={mockCalverProject}
|
||||
setRefetch={jest.fn()}
|
||||
releaseBranch={mockReleaseBranch}
|
||||
/>,
|
||||
@@ -53,11 +56,12 @@ describe('CreateRc', () => {
|
||||
});
|
||||
|
||||
it('should display select element for semver', () => {
|
||||
(useProjectContext as jest.Mock).mockReturnValue(mockSemverProject);
|
||||
|
||||
const { getByTestId } = render(
|
||||
<CreateRc
|
||||
defaultBranch="mockDefaultBranch"
|
||||
latestRelease={mockReleaseVersion}
|
||||
project={mockSemverProject}
|
||||
setRefetch={jest.fn()}
|
||||
releaseBranch={mockReleaseBranch}
|
||||
/>,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import {
|
||||
mockApiClient,
|
||||
mockCalverProject,
|
||||
mockDefaultBranch,
|
||||
mockNextGitHubInfo,
|
||||
mockReleaseVersion,
|
||||
@@ -31,6 +32,7 @@ describe('createRc', () => {
|
||||
defaultBranch: mockDefaultBranch,
|
||||
latestRelease: mockReleaseVersion,
|
||||
nextGitHubInfo: mockNextGitHubInfo,
|
||||
project: mockCalverProject,
|
||||
});
|
||||
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
|
||||
@@ -22,16 +22,17 @@ import {
|
||||
mockReleaseBranch,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => mockCalverProject),
|
||||
}));
|
||||
|
||||
import { Info } from './Info';
|
||||
|
||||
describe('Info', () => {
|
||||
it('should return early if no latestRelease exists', () => {
|
||||
const { getByTestId } = render(
|
||||
<Info
|
||||
latestRelease={null}
|
||||
project={mockCalverProject}
|
||||
releaseBranch={mockReleaseBranch}
|
||||
/>,
|
||||
<Info latestRelease={null} releaseBranch={mockReleaseBranch} />,
|
||||
);
|
||||
|
||||
expect(getByTestId(TEST_IDS.info.info)).toBeInTheDocument();
|
||||
|
||||
@@ -22,6 +22,11 @@ import {
|
||||
mockCalverProject,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => mockCalverProject),
|
||||
}));
|
||||
|
||||
import { Patch } from './Patch';
|
||||
|
||||
describe('Patch', () => {
|
||||
@@ -29,7 +34,6 @@ describe('Patch', () => {
|
||||
const { getByTestId } = render(
|
||||
<Patch
|
||||
latestRelease={null}
|
||||
project={mockCalverProject}
|
||||
setRefetch={jest.fn()}
|
||||
releaseBranch={mockReleaseBranch}
|
||||
/>,
|
||||
|
||||
@@ -18,16 +18,20 @@ import React from 'react';
|
||||
import { render, waitFor, screen } from '@testing-library/react';
|
||||
|
||||
import {
|
||||
mockApiClient,
|
||||
mockBumpedTag,
|
||||
mockCalverProject,
|
||||
mockRcRelease,
|
||||
mockReleaseBranch,
|
||||
mockReleaseVersion,
|
||||
mockTagParts,
|
||||
mockApiClient,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
|
||||
jest.mock('../../components/ProjectContext', () => ({
|
||||
usePluginApiClientContext: () => mockApiClient,
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: jest.fn(() => mockApiClient),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => mockCalverProject),
|
||||
}));
|
||||
|
||||
import { PatchBody } from './PatchBody';
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Alert, AlertTitle } from '@material-ui/lab';
|
||||
import { useAsync, useAsyncFn } from 'react-use';
|
||||
import { Alert, AlertTitle } from '@material-ui/lab';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
@@ -42,14 +42,14 @@ import {
|
||||
SetRefetch,
|
||||
} from '../../types/types';
|
||||
import { CalverTagParts } from '../../helpers/tagParts/getCalverTagParts';
|
||||
import { CenteredCircularProgress } from '../../components/CenteredCircularProgress';
|
||||
import { patch } from './sideEffects/patch';
|
||||
import { ResponseStepList } from '../../components/ResponseStepList/ResponseStepList';
|
||||
import { SemverTagParts } from '../../helpers/tagParts/getSemverTagParts';
|
||||
import { usePluginApiClientContext } from '../../contexts/PluginApiClientContext';
|
||||
import { useStyles } from '../../styles/styles';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { patch } from './sideEffects/patch';
|
||||
import { usePluginApiClientContext } from '../../contexts/PluginApiClientContext';
|
||||
import { useProjectContext } from '../../contexts/ProjectContext';
|
||||
import { CenteredCircularProgress } from '../../components/CenteredCircularProgress';
|
||||
import { useStyles } from '../../styles/styles';
|
||||
|
||||
interface PatchBodyProps {
|
||||
bumpedTag: string;
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
mockApiClient,
|
||||
mockBumpedTag,
|
||||
mockCalverProject,
|
||||
mockReleaseVersion,
|
||||
mockSelectedPatchCommit,
|
||||
mockTagParts,
|
||||
mockApiClient,
|
||||
} from '../../../test-helpers/test-helpers';
|
||||
import { patch } from './patch';
|
||||
|
||||
@@ -33,6 +34,7 @@ describe('patch', () => {
|
||||
bumpedTag: mockBumpedTag,
|
||||
selectedPatchCommit: mockSelectedPatchCommit,
|
||||
tagParts: mockTagParts,
|
||||
project: mockCalverProject,
|
||||
});
|
||||
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
|
||||
@@ -17,12 +17,20 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import { mockRcRelease, mockApiClient } from '../../test-helpers/test-helpers';
|
||||
import {
|
||||
mockApiClient,
|
||||
mockCalverProject,
|
||||
mockRcRelease,
|
||||
} from '../../test-helpers/test-helpers';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../components/ProjectContext', () => ({
|
||||
usePluginApiClientContext: () => mockApiClient,
|
||||
jest.mock('../../contexts/PluginApiClientContext', () => ({
|
||||
usePluginApiClientContext: jest.fn(() => mockApiClient),
|
||||
}));
|
||||
jest.mock('../../contexts/ProjectContext', () => ({
|
||||
useProjectContext: jest.fn(() => mockCalverProject),
|
||||
}));
|
||||
|
||||
import { PromoteRcBody } from './PromoteRcBody';
|
||||
|
||||
describe('PromoteRcBody', () => {
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { CircularProgress } from '@material-ui/core';
|
||||
import { CircularProgress, CircularProgressProps } from '@material-ui/core';
|
||||
|
||||
export const CenteredCircularProgress = () => {
|
||||
export const CenteredCircularProgress = (props: CircularProgressProps) => {
|
||||
return (
|
||||
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
||||
<CircularProgress />
|
||||
<CircularProgress {...props} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user