+14
-8
@@ -13,16 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
const executeShellCommand = jest.fn();
|
||||
const commandExists = jest.fn();
|
||||
const fetchContents = jest.fn();
|
||||
|
||||
jest.doMock('@backstage/plugin-scaffolder-backend', () => ({
|
||||
...require('@backstage/plugin-scaffolder-backend'),
|
||||
fetchContents,
|
||||
executeShellCommand,
|
||||
jest.mock('@backstage/plugin-scaffolder-backend', () => ({
|
||||
...jest.requireActual('@backstage/plugin-scaffolder-backend'),
|
||||
fetchContents: jest.fn(),
|
||||
executeShellCommand: jest.fn(),
|
||||
}));
|
||||
jest.doMock('command-exists', () => commandExists);
|
||||
jest.mock('command-exists', () => jest.fn());
|
||||
|
||||
import {
|
||||
getVoidLogger,
|
||||
@@ -37,9 +34,18 @@ import os from 'os';
|
||||
import { PassThrough } from 'stream';
|
||||
import { createFetchCookiecutterAction } from './cookiecutter';
|
||||
import { join } from 'path';
|
||||
import {
|
||||
fetchContents as fetchContentsMock,
|
||||
executeShellCommand as executeShellCommandMock,
|
||||
} from '@backstage/plugin-scaffolder-backend';
|
||||
import type { ActionContext } from '@backstage/plugin-scaffolder-backend';
|
||||
import commandExistsMock from 'command-exists';
|
||||
|
||||
describe('fetch:cookiecutter', () => {
|
||||
const fetchContents = fetchContentsMock as jest.Mock;
|
||||
const executeShellCommand = executeShellCommandMock as jest.Mock;
|
||||
const commandExists = commandExistsMock as unknown as jest.Mock;
|
||||
|
||||
const integrations = ScmIntegrations.fromConfig(
|
||||
new ConfigReader({
|
||||
integrations: {
|
||||
|
||||
+11
-7
@@ -13,24 +13,28 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import mockfs from 'mock-fs';
|
||||
|
||||
const executeShellCommand = jest.fn();
|
||||
const commandExists = jest.fn();
|
||||
|
||||
jest.doMock('@backstage/plugin-scaffolder-backend', () => ({
|
||||
executeShellCommand,
|
||||
jest.mock('@backstage/plugin-scaffolder-backend', () => ({
|
||||
executeShellCommand: jest.fn(),
|
||||
}));
|
||||
jest.doMock('command-exists', () => commandExists);
|
||||
jest.mock('command-exists', () => jest.fn());
|
||||
jest.mock('fs-extra');
|
||||
|
||||
import { ContainerRunner } from '@backstage/backend-common';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import path from 'path';
|
||||
import { PassThrough } from 'stream';
|
||||
|
||||
import { RailsNewRunner } from './railsNewRunner';
|
||||
|
||||
import { executeShellCommand as executeShellCommandMock } from '@backstage/plugin-scaffolder-backend';
|
||||
import commandExistsMock from 'command-exists';
|
||||
|
||||
describe('Rails Templater', () => {
|
||||
const executeShellCommand = executeShellCommandMock as jest.Mock;
|
||||
const commandExists = commandExistsMock as unknown as jest.Mock;
|
||||
|
||||
const containerRunner: jest.Mocked<ContainerRunner> = {
|
||||
runContainer: jest.fn(),
|
||||
};
|
||||
|
||||
-22
@@ -112,28 +112,6 @@ describe('<TechDocsReaderPageContent />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should render progress if there is no dom and reader state is checking', async () => {
|
||||
getEntityMetadata.mockResolvedValue(mockEntityMetadata);
|
||||
getTechDocsMetadata.mockResolvedValue(mockTechDocsMetadata);
|
||||
(useTechDocsReaderDom as jest.Mock).mockReturnValue(undefined);
|
||||
(useReaderState as jest.Mock).mockReturnValue({ state: 'CHECKING' });
|
||||
|
||||
await act(async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<Wrapper>
|
||||
<TechDocsReaderPageContent withSearch={false} />
|
||||
</Wrapper>,
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
rendered.queryByTestId('techdocs-native-shadowroot'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(rendered.getByRole('progressbar')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render techdocs content if entity metadata is missing', async () => {
|
||||
getEntityMetadata.mockResolvedValue(undefined);
|
||||
(useTechDocsReaderDom as jest.Mock).mockReturnValue(
|
||||
|
||||
Reference in New Issue
Block a user